Compare commits
1 Commits
interactiv
...
RlfInstruc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f8adb70c4 |
@@ -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.workingRegister = 0x1A;
|
Memory.clearCarryBit();
|
||||||
Memory.setRegister(0x14, 0x1B);
|
Memory.setRegister(0x14, 0B11110000); //240 << 224
|
||||||
program.add(CommandDecoder.decode(0x0094));
|
program.add(CommandDecoder.decode(0x0D94));
|
||||||
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();
|
||||||
|
|||||||
36
de/darkress/pic16f84sim/commands/Rlf.java
Normal file
36
de/darkress/pic16f84sim/commands/Rlf.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
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,8 +27,7 @@ public class CommandDecoder
|
|||||||
case 0x800:
|
case 0x800:
|
||||||
return new Movf(input);
|
return new Movf(input);
|
||||||
case 0xD00:
|
case 0xD00:
|
||||||
//rlf();
|
return new Rlf(input);
|
||||||
break;
|
|
||||||
case 0xC00:
|
case 0xC00:
|
||||||
//rrf();
|
//rrf();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -153,9 +153,13 @@ public class Memory
|
|||||||
memory[0x03] &= 0xFD;
|
memory[0x03] &= 0xFD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getCarryBit()
|
public static int getCarryBit()
|
||||||
{
|
{
|
||||||
return (memory[0x03] & 0x01) == 0x01;
|
if((memory[0x03] & 0x01) == 0x01)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCarryBit()
|
public static void setCarryBit()
|
||||||
|
|||||||
Reference in New Issue
Block a user