Co-authored-by: Darkress <30271678+DarkressX@users.noreply.github.com> Reviewed-on: darkress/pic16f84-sim#2
28 lines
618 B
Java
28 lines
618 B
Java
package de.darkress.pic16f84sim.commands;
|
|
|
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
|
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
|
|
|
public class Addlw extends CommandUtils implements Command
|
|
{
|
|
private final int literal;
|
|
|
|
public Addlw(int input)
|
|
{
|
|
literal = input & 0x00FF;
|
|
}
|
|
|
|
@Override
|
|
public void execute()
|
|
{
|
|
int result = literal + Memory.workingRegister;
|
|
|
|
checkZeroBit(result);
|
|
checkCarryBit(result);
|
|
checkDigitCarryBit(literal);
|
|
|
|
Memory.workingRegister = result % 256;
|
|
ProgramCounter.incPC();
|
|
}
|
|
}
|