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(); + } +}