Compare commits
1 Commits
RlfInstruc
...
movwfInstr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30deff96a8 |
@@ -12,9 +12,9 @@ class Main
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
ArrayList<Command> program = new ArrayList<>();
|
ArrayList<Command> program = new ArrayList<>();
|
||||||
Memory.clearCarryBit();
|
Memory.workingRegister = 0x1A;
|
||||||
Memory.setRegister(0x14, 0B11110000); //240 << 224
|
Memory.setRegister(0x14, 0x1B);
|
||||||
program.add(CommandDecoder.decode(0x0D94));
|
program.add(CommandDecoder.decode(0x0094));
|
||||||
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();
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package de.darkress.pic16f84sim.commands;
|
|
||||||
|
|
||||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
|
||||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
|
||||||
|
|
||||||
public class Rlf extends FileRegisterCommandUtils implements Command
|
|
||||||
{
|
|
||||||
private final int address;
|
|
||||||
private final boolean destinationBit;
|
|
||||||
|
|
||||||
public Rlf(int input)
|
|
||||||
{
|
|
||||||
address = input & 0x007F;
|
|
||||||
destinationBit = checkDestinationBit(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute()
|
|
||||||
{
|
|
||||||
int register = Memory.getRegister(address);
|
|
||||||
int carry = Memory.getCarryBit();
|
|
||||||
int tmp = carry;
|
|
||||||
carry = register >>7;
|
|
||||||
register = ((register <<1) + tmp) & 0xFF;
|
|
||||||
|
|
||||||
if(carry == 1)
|
|
||||||
{
|
|
||||||
Memory.setCarryBit();
|
|
||||||
} else if(carry == 0){
|
|
||||||
Memory.clearCarryBit();
|
|
||||||
}
|
|
||||||
|
|
||||||
writeToDestination(destinationBit, address, register);
|
|
||||||
ProgramCounter.incPC();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,8 @@ public class CommandDecoder
|
|||||||
case 0x800:
|
case 0x800:
|
||||||
return new Movf(input);
|
return new Movf(input);
|
||||||
case 0xD00:
|
case 0xD00:
|
||||||
return new Rlf(input);
|
//rlf();
|
||||||
|
break;
|
||||||
case 0xC00:
|
case 0xC00:
|
||||||
//rrf();
|
//rrf();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -153,13 +153,9 @@ public class Memory
|
|||||||
memory[0x03] &= 0xFD;
|
memory[0x03] &= 0xFD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCarryBit()
|
public static boolean getCarryBit()
|
||||||
{
|
{
|
||||||
if((memory[0x03] & 0x01) == 0x01)
|
return (memory[0x03] & 0x01) == 0x01;
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCarryBit()
|
public static void setCarryBit()
|
||||||
|
|||||||
Reference in New Issue
Block a user