Working generic word width
This commit is contained in:
parent
1dab9e69c7
commit
04840349a9
11 changed files with 143 additions and 48 deletions
|
|
@ -3,6 +3,7 @@ package hatelace.instructions;
|
|||
import hatelace.Instruction;
|
||||
import hatelace.Memory;
|
||||
import hatelace.ProgramCounter;
|
||||
import hatelace.IntWord;
|
||||
|
||||
public class Add extends Instruction {
|
||||
private int op1;
|
||||
|
|
@ -16,7 +17,7 @@ public class Add extends Instruction {
|
|||
}
|
||||
|
||||
public void execute(Memory memory, ProgramCounter PC) {
|
||||
memory.write(this.dest, this.op1 + this.op2);
|
||||
memory.write(this.dest, new IntWord(this.op1 + this.op2));
|
||||
PC.incPC();
|
||||
}
|
||||
|
||||
|
|
|
|||
30
app/src/main/java/hatelace/instructions/Copy.java
Normal file
30
app/src/main/java/hatelace/instructions/Copy.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package hatelace.instructions;
|
||||
|
||||
import hatelace.Address;
|
||||
import hatelace.Word;
|
||||
import hatelace.Memory;
|
||||
import hatelace.ProgramCounter;
|
||||
import hatelace.Instruction;
|
||||
|
||||
public class Copy extends Instruction {
|
||||
private Word word;
|
||||
private Address address;
|
||||
|
||||
public Copy(Word word, Address address) {
|
||||
this.word = word;
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public void execute(Memory memory, ProgramCounter PC) {
|
||||
memory.write(this.address.getAddress(), this.word);
|
||||
PC.incPC();
|
||||
}
|
||||
|
||||
protected String opcode() {
|
||||
return "copy";
|
||||
}
|
||||
|
||||
protected Object[] operands() {
|
||||
return new Object[] {this.word, this.address};
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package hatelace.instructions;
|
|||
import hatelace.Instruction;
|
||||
import hatelace.Memory;
|
||||
import hatelace.ProgramCounter;
|
||||
import hatelace.IntWord;
|
||||
|
||||
public class Mul extends Instruction {
|
||||
private int op1;
|
||||
|
|
@ -16,7 +17,7 @@ public class Mul extends Instruction {
|
|||
}
|
||||
|
||||
public void execute(Memory memory, ProgramCounter PC) {
|
||||
memory.write(this.dest, this.op1 * this.op2);
|
||||
memory.write(this.dest, new IntWord(this.op1 * this.op2));
|
||||
PC.incPC();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue