Compare commits

...

2 Commits

Author SHA1 Message Date
Darkress
34f9d4b9d5 implemented Iorwf Instruction 2023-06-03 23:28:47 +02:00
darkress
1a9f2436ef implemented Clrf Instruction (#16)
Co-authored-by: darkress <30271678+DarkressX@users.noreply.github.com>
Reviewed-on: darkress/pic16f84-sim#16
2023-06-02 23:54:20 +02:00
4 changed files with 59 additions and 6 deletions

View File

@@ -12,8 +12,9 @@ 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.workingRegister = 0B11001100;
Memory.setRegister(0x14, 0B11110000);
program.add(CommandDecoder.decode(0x0414));
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

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

View File

@@ -23,8 +23,7 @@ public class CommandDecoder
case 0xF00:
return new Incfsz(input);
case 0x400:
//iorwf();
break;
return new Iorwf(input);
case 0x800:
//movf();
break;
@@ -54,8 +53,7 @@ public class CommandDecoder
switch(input & 0x3F80)
{
case 0x180:
//clrf();
break;
return new Clrf(input);
case 0x100:
return new Clrw();
case 0x80: