HateLace/app/src/main/java/hatelace/instructions/Add.java

31 lines
655 B
Java
Raw Normal View History

2024-04-16 07:58:37 +02:00
package hatelace.instructions;
import hatelace.Instruction;
import hatelace.Memory;
import hatelace.ProgramCounter;
public class Add extends Instruction {
private int op1;
private int op2;
private int dest;
public Add(int op1, int op2, int dest) {
this.op1 = op1;
this.op2 = op2;
this.dest = dest;
}
public void execute(Memory memory, ProgramCounter PC) {
memory.write(this.dest, this.op1 + this.op2);
PC.incPC();
}
protected String opcode() {
return "add";
}
protected Object[] operands() {
return new Object[] {this.op1, this.op2, this.dest};
}
}