This commit is contained in:
2024-05-14 17:17:27 +02:00
parent 8f35f4f914
commit 2258c5a8be
3 changed files with 34 additions and 12 deletions

View File

@ -214,7 +214,7 @@ public class Commands {
return; return;
case 0b01100011: case 0b01100011:
System.out.println("SLEEP"); System.out.println("SLEEP");
//TODO SLEEP();
addExecutionTime(1); addExecutionTime(1);
return; return;
default: default:
@ -222,8 +222,7 @@ public class Commands {
} }
if (instruction == 0 || instruction == 0b0110000 || instruction == 0b01000000 || instruction == 0b00100000){ if (instruction == 0 || instruction == 0b0110000 || instruction == 0b01000000 || instruction == 0b00100000){
System.out.println("NOP"); NOP ();
addExecutionTime(1);
} }
else{ else{
System.out.println("Nicht gefunden!"); System.out.println("Nicht gefunden!");
@ -232,10 +231,19 @@ public class Commands {
} }
public static void SLEEP() {
Controller_Frontend.sleep ();
}
public static void RETFIE() { public static void RETFIE() {
DataRegister.setPC(ProgramStack.pop()); DataRegister.setPC(ProgramStack.pop());
} }
public static void NOP () {
System.out.println("NOP");
addExecutionTime(1);
}
public static void GOTO(int jump) { public static void GOTO(int jump) {
DataRegister.setPC(jump-1); DataRegister.setPC(jump-1);
} }

View File

@ -79,10 +79,18 @@ public class Controller_Frontend {
private CheckBox wdtCheck; private CheckBox wdtCheck;
private static volatile boolean isAutoRunActive = true; private static volatile boolean isAutoRunActive = true;
private static volatile boolean isSleeping = false;
public static void stopRunFromBackend(){ public static void stopRunFromBackend(){
isAutoRunActive = false; isAutoRunActive = false;
if (isSleeping)
isSleeping = false;
else
DataRegister.resetPC();
}
public static void sleep() {
isSleeping = true;
} }
@FXML @FXML
@ -153,8 +161,12 @@ public class Controller_Frontend {
}); });
// Befehle ausführen // Befehle ausführen
Commands.decode(prog[DataRegister.getPC()]); if (!isSleeping) {
DataRegister.increasePC(); Commands.decode(prog[DataRegister.getPC()]);
DataRegister.increasePC();
}
else
Commands.decode(0);
WatchdogTimer.testAndTrigger(); WatchdogTimer.testAndTrigger();
Table.refresh(); Table.refresh();
Stage stage = (Stage) stepintoButton.getScene().getWindow(); Stage stage = (Stage) stepintoButton.getScene().getWindow();

View File

@ -11,12 +11,14 @@ public class WatchdogTimer {
public static void testAndTrigger() { public static void testAndTrigger() {
watchdogTime = getTimeFromRegister() * 1000; watchdogTime = getTimeFromRegister() * 1000;
if (enabled && (Commands.getTotalExecutionTime() >= (watchdogTime + lastReset - 1))){ if (enabled) {
DataRegister.resetPC(); System.err.println("Remaining: " + ((watchdogTime + lastReset - 1) - Commands.getTotalExecutionTime()));
System.err.println("Watchdog Timer triggered"); if (Commands.getTotalExecutionTime() >= (watchdogTime + lastReset - 1)) {
DataRegister.clearBit(3, 4); System.err.println("Watchdog Timer triggered");
lastReset = Commands.getTotalExecutionTime(); DataRegister.clearBit(3, 4);
Controller_Frontend.stopRunFromBackend(); lastReset = Commands.getTotalExecutionTime();
Controller_Frontend.stopRunFromBackend();
}
} }
} }