Compare commits

..

2 Commits

Author SHA1 Message Date
darkress
9a21d9256f implemented Clrf Instruction 2023-06-02 23:50:34 +02:00
darkress
ab9f378d34 implemented Clrw instruction (#15)
Co-authored-by: darkress <github@darkress.xyz>
Reviewed-on: darkress/pic16f84-sim#15
2023-06-02 23:29:15 +02:00
3 changed files with 30 additions and 4 deletions

View File

@@ -12,8 +12,8 @@ class Main
public static void main(String[] args) {
ArrayList<Command> program = new ArrayList<>();
Memory.workingRegister = 0x10;
program.add(CommandDecoder.decode(0x123)); //Write 0x11 to W
Memory.setRegister(0x14, 0xFF);
program.add(CommandDecoder.decode(0x0194));
for(int i = 0; i < program.size(); i++)
{
program.get(ProgramCounter.getPc()).execute();

View File

@@ -0,0 +1,27 @@
package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
public class Clrf extends FileRegisterCommandUtils implements Command
{
private final int address;
private final boolean destinationBit;
public Clrf(int input)
{
address = input & 0x007F;
destinationBit = true;
}
@Override
public void execute()
{
final int result = 0;
checkZeroBit(result);
writeToDestination(destinationBit, address, result);
ProgramCounter.incPC();
}
}

View File

@@ -54,8 +54,7 @@ public class CommandDecoder
switch(input & 0x3F80)
{
case 0x180:
//clrf();
break;
return new Clrf(input);
case 0x100:
return new Clrw();
case 0x80: