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