diff --git a/de/darkress/pic16f84sim/Main.java b/de/darkress/pic16f84sim/Main.java index dbe245e..7d10664 100644 --- a/de/darkress/pic16f84sim/Main.java +++ b/de/darkress/pic16f84sim/Main.java @@ -15,7 +15,7 @@ class Main int input1 = 0x27FF; program.add(CommandDecoder.decode(0x3011)); //Write 0x11 to W Memory.setRegister(0x14, 0x14); - program.add(CommandDecoder.decode(0x0594)); + program.add(CommandDecoder.decode(0x0994)); for(int i = 0; i < 2; i++) { program.get(ProgramCounter.getPc()).execute(); diff --git a/de/darkress/pic16f84sim/commands/Comf.java b/de/darkress/pic16f84sim/commands/Comf.java new file mode 100644 index 0000000..f28c6df --- /dev/null +++ b/de/darkress/pic16f84sim/commands/Comf.java @@ -0,0 +1,27 @@ +package de.darkress.pic16f84sim.commands; + +import de.darkress.pic16f84sim.microcontroller.Memory; +import de.darkress.pic16f84sim.microcontroller.ProgramCounter; + +public class Comf extends FileRegisterCommandUtils implements Command +{ + private final int address; + private final boolean destinationBit; + + public Comf(int input) + { + address = input & 0x007F; + destinationBit = checkDestinationBit(input); + } + + @Override + public void execute() + { + int result = 255 - Memory.getRegister(address); // Get inverse of 8Bit value + + checkZeroBit(result); + + writeToDestination(destinationBit, address, result); + ProgramCounter.incPC(); + } +} diff --git a/de/darkress/pic16f84sim/decoder/CommandDecoder.java b/de/darkress/pic16f84sim/decoder/CommandDecoder.java index 9a2318c..972ac57 100644 --- a/de/darkress/pic16f84sim/decoder/CommandDecoder.java +++ b/de/darkress/pic16f84sim/decoder/CommandDecoder.java @@ -13,8 +13,7 @@ public class CommandDecoder case 0x500: return new Andwf(input); case 0x900: - //comf(); - break; + return new Comf(input); case 0x300: //decf(); break;