29 lines
639 B
Java
29 lines
639 B
Java
package hatelace.instructions;
|
|
|
|
import hatelace.*;
|
|
|
|
public class Print implements Instruction {
|
|
private Address address;
|
|
|
|
/** Print content of memory address */
|
|
public Print(Address address) {
|
|
this.address = address;
|
|
}
|
|
|
|
public void execute(Memory memory, ProgramCounter PC) {
|
|
System.out.println(memory.read(this.address));
|
|
PC.incPC();
|
|
}
|
|
|
|
public String opcode() {
|
|
return "PRT";
|
|
}
|
|
|
|
public Object[] operands() {
|
|
return new Object[] { this.address };
|
|
}
|
|
|
|
public String toString() {
|
|
return String.format("%s [%s]", this.opcode(), this.address);
|
|
}
|
|
}
|