Compare commits
1 Commits
timer0
...
RrfInstruc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c7dbdb548 |
@@ -13,8 +13,8 @@ class Main
|
|||||||
|
|
||||||
ArrayList<Command> program = new ArrayList<>();
|
ArrayList<Command> program = new ArrayList<>();
|
||||||
Memory.clearCarryBit();
|
Memory.clearCarryBit();
|
||||||
Memory.setRegister(0x14, 0B11110000); //240 << 224
|
Memory.setRegister(0x14, 0B00000001); //240 << 224
|
||||||
program.add(CommandDecoder.decode(0x0D94));
|
program.add(CommandDecoder.decode(0x0C94));
|
||||||
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();
|
||||||
|
|||||||
@@ -18,15 +18,14 @@ public class Rlf extends FileRegisterCommandUtils implements Command
|
|||||||
public void execute()
|
public void execute()
|
||||||
{
|
{
|
||||||
int register = Memory.getRegister(address);
|
int register = Memory.getRegister(address);
|
||||||
int carry = Memory.getCarryBit();
|
int newCarry = register >>7;
|
||||||
int tmp = carry;
|
int oldCarry = Memory.getCarryBit();
|
||||||
carry = register >>7;
|
register = ((register <<1) + oldCarry) & 0xFF;
|
||||||
register = ((register <<1) + tmp) & 0xFF;
|
|
||||||
|
|
||||||
if(carry == 1)
|
if(newCarry == 1)
|
||||||
{
|
{
|
||||||
Memory.setCarryBit();
|
Memory.setCarryBit();
|
||||||
} else if(carry == 0){
|
} else if(newCarry == 0){
|
||||||
Memory.clearCarryBit();
|
Memory.clearCarryBit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
35
de/darkress/pic16f84sim/commands/Rrf.java
Normal file
35
de/darkress/pic16f84sim/commands/Rrf.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package de.darkress.pic16f84sim.commands;
|
||||||
|
|
||||||
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||||
|
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||||
|
|
||||||
|
public class Rrf extends FileRegisterCommandUtils implements Command
|
||||||
|
{
|
||||||
|
private final int address;
|
||||||
|
private final boolean destinationBit;
|
||||||
|
|
||||||
|
public Rrf(int input)
|
||||||
|
{
|
||||||
|
address = input & 0x007F;
|
||||||
|
destinationBit = checkDestinationBit(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute()
|
||||||
|
{
|
||||||
|
int register = Memory.getRegister(address);
|
||||||
|
int newCarry = register & 0x01;
|
||||||
|
int oldCarry = Memory.getCarryBit();
|
||||||
|
register = (oldCarry << 7) + (register >>1);
|
||||||
|
|
||||||
|
if(newCarry == 1)
|
||||||
|
{
|
||||||
|
Memory.setCarryBit();
|
||||||
|
} else if(newCarry == 0){
|
||||||
|
Memory.clearCarryBit();
|
||||||
|
}
|
||||||
|
|
||||||
|
writeToDestination(destinationBit, address, register);
|
||||||
|
ProgramCounter.incPC();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,8 +29,7 @@ public class CommandDecoder
|
|||||||
case 0xD00:
|
case 0xD00:
|
||||||
return new Rlf(input);
|
return new Rlf(input);
|
||||||
case 0xC00:
|
case 0xC00:
|
||||||
//rrf();
|
return new Rrf(input);
|
||||||
break;
|
|
||||||
case 0x200:
|
case 0x200:
|
||||||
//subwf();
|
//subwf();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user