Instructions
This commit is contained in:
parent
04840349a9
commit
b301ba7669
3 changed files with 15 additions and 11 deletions
|
@ -4,20 +4,22 @@ import hatelace.Instruction;
|
|||
import hatelace.Memory;
|
||||
import hatelace.ProgramCounter;
|
||||
import hatelace.IntWord;
|
||||
import hatelace.Word;
|
||||
import hatelace.Address;
|
||||
|
||||
public class Add extends Instruction {
|
||||
private int op1;
|
||||
private int op2;
|
||||
private int dest;
|
||||
private Word op1;
|
||||
private Word op2;
|
||||
private Address dest;
|
||||
|
||||
public Add(int op1, int op2, int dest) {
|
||||
public Add(Word op1, Word op2, Address dest) {
|
||||
this.op1 = op1;
|
||||
this.op2 = op2;
|
||||
this.dest = dest;
|
||||
}
|
||||
|
||||
public void execute(Memory memory, ProgramCounter PC) {
|
||||
memory.write(this.dest, new IntWord(this.op1 + this.op2));
|
||||
memory.write(this.dest, new IntWord(op1.add(op2)));
|
||||
PC.incPC();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class Copy extends Instruction {
|
|||
}
|
||||
|
||||
public void execute(Memory memory, ProgramCounter PC) {
|
||||
memory.write(this.address.getAddress(), this.word);
|
||||
memory.write(this.address, this.word);
|
||||
PC.incPC();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
package hatelace.instructions;
|
||||
|
||||
import hatelace.Address;
|
||||
import hatelace.Word;
|
||||
import hatelace.Instruction;
|
||||
import hatelace.Memory;
|
||||
import hatelace.ProgramCounter;
|
||||
import hatelace.IntWord;
|
||||
|
||||
public class Mul extends Instruction {
|
||||
private int op1;
|
||||
private int op2;
|
||||
private int dest;
|
||||
private Word op1;
|
||||
private Word op2;
|
||||
private Address dest;
|
||||
|
||||
public Mul(int op1, int op2, int dest) {
|
||||
public Mul(Word op1, Word op2, Address dest) {
|
||||
this.op1 = op1;
|
||||
this.op2 = op2;
|
||||
this.dest = dest;
|
||||
}
|
||||
|
||||
public void execute(Memory memory, ProgramCounter PC) {
|
||||
memory.write(this.dest, new IntWord(this.op1 * this.op2));
|
||||
memory.write(this.dest, new IntWord(op1.multiply(op2)));
|
||||
PC.incPC();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue