Interrupts/Call
This commit is contained in:
@ -47,7 +47,7 @@ public class Commands {
|
|||||||
switch (instruction & 0x3800){
|
switch (instruction & 0x3800){
|
||||||
case 0b10000000000000:
|
case 0b10000000000000:
|
||||||
System.out.println("CALL: " + j);
|
System.out.println("CALL: " + j);
|
||||||
CALL (j, true);
|
CALL (j);
|
||||||
addExecutionTime(2);
|
addExecutionTime(2);
|
||||||
return;
|
return;
|
||||||
case 0b10100000000000:
|
case 0b10100000000000:
|
||||||
@ -271,13 +271,9 @@ public class Commands {
|
|||||||
DataRegister.setPC(jump-1);
|
DataRegister.setPC(jump-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CALL(int jump, boolean normalUse) {
|
public static void CALL(int jump) {
|
||||||
ProgramStack.push(DataRegister.getPC()+1);
|
ProgramStack.push(DataRegister.getPC()+1);
|
||||||
if (normalUse)
|
DataRegister.setPC(jump-1);
|
||||||
DataRegister.setPC(jump-1);
|
|
||||||
else
|
|
||||||
DataRegister.setPC(jump);
|
|
||||||
|
|
||||||
addExecutionTime(1);
|
addExecutionTime(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -96,11 +96,11 @@ public class Controller_Frontend {
|
|||||||
return isSleeping;
|
return isSleeping;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopRunFromBackend(String message, boolean resetPC){
|
public static void stopRunFromBackend(String message){
|
||||||
isAutoRunActive = false;
|
isAutoRunActive = false;
|
||||||
if (isSleeping)
|
if (isSleeping)
|
||||||
isSleeping = false;
|
wakeUpFromSleep();
|
||||||
else if (resetPC)
|
else
|
||||||
DataRegister.resetPC();
|
DataRegister.resetPC();
|
||||||
// Stage stoppedStage = new Stage();
|
// Stage stoppedStage = new Stage();
|
||||||
// stoppedStage.setTitle("Programm unterbrochen!");
|
// stoppedStage.setTitle("Programm unterbrochen!");
|
||||||
@ -122,15 +122,16 @@ public class Controller_Frontend {
|
|||||||
isSleeping = true;
|
isSleeping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void wakeUpFromSleep() {
|
||||||
|
isSleeping = false;
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void stopAutoRun(ActionEvent event) {
|
private void stopAutoRun(ActionEvent event) {
|
||||||
isAutoRunActive = false;
|
isAutoRunActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void autoRunGUI(ActionEvent event) {
|
private void autoRunGUI(ActionEvent event) {
|
||||||
if (!isAutoRunActive) {
|
if (!isAutoRunActive) {
|
||||||
@ -155,7 +156,6 @@ public class Controller_Frontend {
|
|||||||
});
|
});
|
||||||
autoRunThread.setDaemon(true);
|
autoRunThread.setDaemon(true);
|
||||||
autoRunThread.start();
|
autoRunThread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -259,7 +259,6 @@ public class Controller_Frontend {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////testeteet
|
|
||||||
private Set<Integer> breakpoints = new HashSet<>();
|
private Set<Integer> breakpoints = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
@ -293,9 +292,6 @@ public class Controller_Frontend {
|
|||||||
displayLSTFileContent(selectedFile);
|
displayLSTFileContent(selectedFile);
|
||||||
markSelectedRow(0, "-fx-background-color: red; -fx-text-fill: white;");
|
markSelectedRow(0, "-fx-background-color: red; -fx-text-fill: white;");
|
||||||
initializeBreakpoints();
|
initializeBreakpoints();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -347,13 +343,6 @@ public class Controller_Frontend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private File chooseLSTFile() {
|
private File chooseLSTFile() {
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
fileChooser.setTitle("Open LST File");
|
fileChooser.setTitle("Open LST File");
|
||||||
|
|||||||
@ -13,18 +13,22 @@ public class Interrupts {
|
|||||||
private static final int INTE = 0x4;
|
private static final int INTE = 0x4;
|
||||||
private static final int INTF = 0x1;
|
private static final int INTF = 0x1;
|
||||||
|
|
||||||
public static void triggerTMR0() {
|
public static void triggerTMR0(boolean manual) {
|
||||||
triggerInterrupt(T0IF, T0IE);
|
triggerInterrupt(T0IF, T0IE);
|
||||||
|
if (manual)
|
||||||
|
DataRegister.increasePC();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void triggerInterrupt(int flag, int enableFlag) {
|
private static void triggerInterrupt(int flag, int enableFlag) {
|
||||||
DataRegister.setBit(INTCON, flag);
|
DataRegister.setBit(INTCON, flag);
|
||||||
enableFlag = DataRegister.getDirectBit(INTCON, enableFlag);
|
enableFlag = DataRegister.getDirectBit(INTCON, enableFlag);
|
||||||
int globalFlag = DataRegister.getDirectBit(INTCON, GIE);
|
int globalFlag = DataRegister.getDirectBit(INTCON, GIE);
|
||||||
if (globalFlag == 1 && enableFlag == 1) {
|
if (enableFlag == 1) {
|
||||||
DataRegister.clearBit(INTCON, GIE);
|
Controller_Frontend.wakeUpFromSleep();
|
||||||
Commands.CALL(ISR, false);
|
if (globalFlag == 1) {
|
||||||
Controller_Frontend.stopRunFromBackend("Interrupt", false);
|
DataRegister.clearBit(INTCON, GIE);
|
||||||
|
Commands.CALL(ISR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +36,7 @@ public class Interrupts {
|
|||||||
public static void triggerRBInterrupt(int oldValue, int newValue) {
|
public static void triggerRBInterrupt(int oldValue, int newValue) {
|
||||||
if (newValue != oldValue){
|
if (newValue != oldValue){
|
||||||
triggerInterrupt(RBIF, RBIE);
|
triggerInterrupt(RBIF, RBIE);
|
||||||
|
DataRegister.increasePC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +50,7 @@ public class Interrupts {
|
|||||||
if (oldValue == 1 && newValue == 0)
|
if (oldValue == 1 && newValue == 0)
|
||||||
triggerInterrupt(INTF, INTE);
|
triggerInterrupt(INTF, INTE);
|
||||||
}
|
}
|
||||||
|
DataRegister.increasePC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public class PreScaler {
|
|||||||
scaler--;
|
scaler--;
|
||||||
if (scaler == 0) {
|
if (scaler == 0) {
|
||||||
scaler = getFactor();
|
scaler = getFactor();
|
||||||
Timer.increment();
|
Timer.increment(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public class Timer {
|
|||||||
PreScaler.decrement();
|
PreScaler.decrement();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
increment();
|
increment(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ public class Timer {
|
|||||||
if (PreScaler.isPrescalerOnTimer())
|
if (PreScaler.isPrescalerOnTimer())
|
||||||
PreScaler.decrement();
|
PreScaler.decrement();
|
||||||
else
|
else
|
||||||
increment();
|
increment(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// High to low
|
// High to low
|
||||||
@ -41,7 +41,7 @@ public class Timer {
|
|||||||
if (PreScaler.isPrescalerOnTimer())
|
if (PreScaler.isPrescalerOnTimer())
|
||||||
PreScaler.decrement();
|
PreScaler.decrement();
|
||||||
else
|
else
|
||||||
increment();
|
increment(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oldpin = newpin;
|
oldpin = newpin;
|
||||||
@ -49,11 +49,11 @@ public class Timer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void increment() {
|
public static void increment(boolean manual) {
|
||||||
int timer = DataRegister.getDirectRegister(TIMERREG);
|
int timer = DataRegister.getDirectRegister(TIMERREG);
|
||||||
timer++;
|
timer++;
|
||||||
if (timer > 0xFF){
|
if (timer > 0xFF){
|
||||||
Interrupts.triggerTMR0 ();
|
Interrupts.triggerTMR0(manual);
|
||||||
DataRegister.setDirectRegister(TIMERREG, 0);
|
DataRegister.setDirectRegister(TIMERREG, 0);
|
||||||
} else {
|
} else {
|
||||||
DataRegister.setDirectRegister(1, timer);
|
DataRegister.setDirectRegister(1, timer);
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public class WatchdogTimer {
|
|||||||
if (Commands.getTotalExecutionTime() >= (watchdogTime + lastReset - 1)) {
|
if (Commands.getTotalExecutionTime() >= (watchdogTime + lastReset - 1)) {
|
||||||
DataRegister.clearBit(3, 4);
|
DataRegister.clearBit(3, 4);
|
||||||
lastReset = Commands.getTotalExecutionTime();
|
lastReset = Commands.getTotalExecutionTime();
|
||||||
Controller_Frontend.stopRunFromBackend("Watchdog Timer", true);
|
Controller_Frontend.stopRunFromBackend("Watchdog Timer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user