* Added addlw command * Write to program list * Included CommandUtils as helpter class. Sorted classes into packages * Revert changes on HelloWorld * Revert "Revert changes on HelloWorld" This reverts commit a08a336864fb2aa2bbc5a4e37ca360765774965e. * Added example execution of Addlw command
26 lines
477 B
Java
26 lines
477 B
Java
package commands;
|
|
|
|
import registers.Memory;
|
|
|
|
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(result, literal);
|
|
|
|
Memory.workingRegister = result % 256;
|
|
}
|
|
}
|