From e18ec6d167f95247210095613c5b2178b2bccf8e Mon Sep 17 00:00:00 2001 From: Darkress <30271678+DarkressX@users.noreply.github.com> Date: Wed, 31 May 2023 20:22:38 +0200 Subject: [PATCH] Started implementation of decfsz Instruction --- de/darkress/pic16f84sim/commands/Decfsz.java | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 de/darkress/pic16f84sim/commands/Decfsz.java diff --git a/de/darkress/pic16f84sim/commands/Decfsz.java b/de/darkress/pic16f84sim/commands/Decfsz.java new file mode 100644 index 0000000..8f5c1b1 --- /dev/null +++ b/de/darkress/pic16f84sim/commands/Decfsz.java @@ -0,0 +1,27 @@ +package de.darkress.pic16f84sim.commands; + +import de.darkress.pic16f84sim.microcontroller.Memory; +import de.darkress.pic16f84sim.microcontroller.ProgramCounter; + +public class Decfsz extends FileRegisterCommandUtils implements Command +{ + private final int address; + private final boolean destinationBit; + + public Decfsz(int input) + { + address = input & 0x007F; + destinationBit = checkDestinationBit(input); + } + + @Override + public void execute() + { + int result = Memory.getRegister(address) + 255; // Allow underflow + + checkZeroBit(result); + + writeToDestination(destinationBit, address, result % 256); // Catch underflow + ProgramCounter.incPC(); + } +}