implemented btfss Instruction #28

Merged
Darkress merged 1 commits from btfssInstruction into main 2023-06-07 21:34:24 +02:00
3 changed files with 32 additions and 6 deletions
Showing only changes of commit 5f1ba4e9e6 - Show all commits

View File

@@ -13,8 +13,8 @@ class Main
ArrayList<Command> program = new ArrayList<>(); ArrayList<Command> program = new ArrayList<>();
Memory.workingRegister = 0x01; Memory.workingRegister = 0x01;
Memory.setRegister(0x14, 0xA5); //240 << 224 Memory.setRegister(0x14, 0xA7); //240 << 224
program.add(CommandDecoder.decode(0x1894)); program.add(CommandDecoder.decode(0x1C94));
for(int i = 0; i < program.size(); i++) for(int i = 0; i < program.size(); i++)
{ {
program.get(ProgramCounter.getPc()).execute(); program.get(ProgramCounter.getPc()).execute();

View File

@@ -0,0 +1,29 @@
package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
public class Btfss extends BitOrientedCommandUtils implements Command
{
private final int address;
private int bitPlacement;
public Btfss(int input)
{
address = input & 0x007F;
bitPlacement = checkBitPlacement(input);
}
@Override
public void execute()
{
int result = Memory.getRegister(address);
if((result & (1 << bitPlacement)) > 0) //Test if bit is set
{
ProgramCounter.incPC();
}
ProgramCounter.incPC();
}
}

View File

@@ -63,16 +63,13 @@ public class CommandDecoder
case 0x1800: case 0x1800:
return new Btfsc(input); return new Btfsc(input);
case 0x1C00: case 0x1C00:
//btfss(); return new Btfss(input);
break;
} }
switch(input & 0x3E00) switch(input & 0x3E00)
{ {
case 0x3E00: case 0x3E00:
//addlw();
return new Addlw(input); return new Addlw(input);
//break;
case 0x3C00: case 0x3C00:
return new Sublw(input); return new Sublw(input);
} }