Compare commits
2 Commits
subwfInstr
...
swapfInstr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c3ed8a1b2 | ||
|
|
d8ed3ab9b1 |
@@ -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, 0x01); //240 << 224
|
Memory.setRegister(0x14, 0xA5); //240 << 224
|
||||||
program.add(CommandDecoder.decode(0x0294));
|
program.add(CommandDecoder.decode(0x0E94));
|
||||||
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();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class Decfsz extends FileRegisterCommandUtils implements Command
|
|||||||
if((result % 256) == 0)
|
if((result % 256) == 0)
|
||||||
{
|
{
|
||||||
Nop nop = new Nop();
|
Nop nop = new Nop();
|
||||||
nop.execute();
|
nop.execute(); // TODO: What happens if an interrupt gets triggered during the nop execution?
|
||||||
}
|
}
|
||||||
ProgramCounter.incPC();
|
ProgramCounter.incPC();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class Incfsz extends FileRegisterCommandUtils implements Command
|
|||||||
if((result % 256) == 0)
|
if((result % 256) == 0)
|
||||||
{
|
{
|
||||||
Nop nop = new Nop();
|
Nop nop = new Nop();
|
||||||
nop.execute();
|
nop.execute(); // TODO: What happens if an interrupt gets triggered during the nop execution?
|
||||||
}
|
}
|
||||||
ProgramCounter.incPC();
|
ProgramCounter.incPC();
|
||||||
}
|
}
|
||||||
|
|||||||
27
de/darkress/pic16f84sim/commands/Swapf.java
Normal file
27
de/darkress/pic16f84sim/commands/Swapf.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package de.darkress.pic16f84sim.commands;
|
||||||
|
|
||||||
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||||
|
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||||
|
|
||||||
|
public class Swapf extends FileRegisterCommandUtils implements Command
|
||||||
|
{
|
||||||
|
private final int address;
|
||||||
|
private final boolean destinationBit;
|
||||||
|
|
||||||
|
public Swapf(int input)
|
||||||
|
{
|
||||||
|
address = input & 0x007F;
|
||||||
|
destinationBit = checkDestinationBit(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute()
|
||||||
|
{
|
||||||
|
int result = (Memory.getRegister(address) <<4) & 0xF0;
|
||||||
|
int tmp = Memory.getRegister(address) >>4;
|
||||||
|
result += tmp;
|
||||||
|
|
||||||
|
writeToDestination(destinationBit, address, result);
|
||||||
|
ProgramCounter.incPC();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,8 +33,7 @@ public class CommandDecoder
|
|||||||
case 0x200:
|
case 0x200:
|
||||||
return new Subwf(input);
|
return new Subwf(input);
|
||||||
case 0xE00:
|
case 0xE00:
|
||||||
//swapf();
|
return new Swapf(input);
|
||||||
break;
|
|
||||||
case 0x600:
|
case 0x600:
|
||||||
//xorwf();
|
//xorwf();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user