From 02f7e528561f6fe44d0d4d70090ee3fb9955e391 Mon Sep 17 00:00:00 2001 From: Darkress <30271678+DarkressX@users.noreply.github.com> Date: Sat, 17 Jun 2023 22:51:46 +0200 Subject: [PATCH] implemented Clrwdt Instruction --- de/darkress/pic16f84sim/commands/Clrwdt.java | 24 +++++++++++++++++++ .../pic16f84sim/decoder/CommandDecoder.java | 2 +- .../pic16f84sim/microcontroller/Watchdog.java | 4 ++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 de/darkress/pic16f84sim/commands/Clrwdt.java diff --git a/de/darkress/pic16f84sim/commands/Clrwdt.java b/de/darkress/pic16f84sim/commands/Clrwdt.java new file mode 100644 index 0000000..7f3482e --- /dev/null +++ b/de/darkress/pic16f84sim/commands/Clrwdt.java @@ -0,0 +1,24 @@ +package de.darkress.pic16f84sim.commands; + +import de.darkress.pic16f84sim.microcontroller.*; + +public class Clrwdt extends LiteralCommandUtils implements Command +{ + + public Clrwdt() + { + } + + @Override + public void execute() + { + ProgramCounter.incPC(); + Cycles.incCycles(); + + Memory.setRegister(0x03, Memory.getRegister(0x03) | 0x18); + if(Timer.getPrescalerAssignment()) { + Timer.resetTimeToTimerIncrease(); + Watchdog.resetWatchdogTimer(); + } + } +} diff --git a/de/darkress/pic16f84sim/decoder/CommandDecoder.java b/de/darkress/pic16f84sim/decoder/CommandDecoder.java index 10eea94..0d480d0 100644 --- a/de/darkress/pic16f84sim/decoder/CommandDecoder.java +++ b/de/darkress/pic16f84sim/decoder/CommandDecoder.java @@ -97,7 +97,7 @@ public class CommandDecoder if (input == 0x0064) { - //clrwdt(); + return new Clrwdt(); } if (input == 0x0009) diff --git a/de/darkress/pic16f84sim/microcontroller/Watchdog.java b/de/darkress/pic16f84sim/microcontroller/Watchdog.java index a3db386..ea0b81f 100644 --- a/de/darkress/pic16f84sim/microcontroller/Watchdog.java +++ b/de/darkress/pic16f84sim/microcontroller/Watchdog.java @@ -8,6 +8,10 @@ public class Watchdog return watchdogTimer; } + public static void resetWatchdogTimer() { + watchdogTimer = 18000; + } + public static void decreaseWatchdogTimer() { watchdogTimer--; -- 2.49.1