Compare commits
1 Commits
bsfInstruc
...
bcfInstruc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a58176dfef |
@@ -14,7 +14,7 @@ class Main
|
||||
ArrayList<Command> program = new ArrayList<>();
|
||||
Memory.workingRegister = 0x01;
|
||||
Memory.setRegister(0x14, 0xA5); //240 << 224
|
||||
program.add(CommandDecoder.decode(0x0694));
|
||||
program.add(CommandDecoder.decode(0x1114));
|
||||
for(int i = 0; i < program.size(); i++)
|
||||
{
|
||||
program.get(ProgramCounter.getPc()).execute();
|
||||
|
||||
26
de/darkress/pic16f84sim/commands/Bcf.java
Normal file
26
de/darkress/pic16f84sim/commands/Bcf.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
public class Bcf extends BitOrientedCommandUtils implements Command
|
||||
{
|
||||
private final int address;
|
||||
private int bitPlacement;
|
||||
|
||||
public Bcf(int input)
|
||||
{
|
||||
address = input & 0x007F;
|
||||
bitPlacement = checkBitPlacement(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
int result = Memory.getRegister(address);
|
||||
result &= ~(1 << bitPlacement); //Mask n-th bit with 0
|
||||
|
||||
Memory.setRegister(address, result);
|
||||
ProgramCounter.incPC();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
|
||||
public class BitOrientedCommandUtils
|
||||
{
|
||||
protected int checkBitPlacement(int input)
|
||||
{
|
||||
return ((input & 0x0380) >>7);
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,7 @@ public class CommandDecoder
|
||||
switch(input & 0x3C00)
|
||||
{
|
||||
case 0x1000:
|
||||
//bcf();
|
||||
break;
|
||||
return new Bcf(input);
|
||||
case 0x1400:
|
||||
//bsf();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user