implemented Rlf Instruction (#20)
Co-authored-by: Darkress <30271678+DarkressX@users.noreply.github.com> Reviewed-on: darkress/pic16f84-sim#20
This commit was merged in pull request #20.
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user