mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
Comments!
This commit is contained in:
parent
974b00aa7a
commit
3db05478c1
@ -4,10 +4,12 @@ import net.simon987.server.assembly.CPU;
|
|||||||
import net.simon987.server.assembly.Instruction;
|
import net.simon987.server.assembly.Instruction;
|
||||||
import net.simon987.server.assembly.Status;
|
import net.simon987.server.assembly.Status;
|
||||||
/**
|
/**
|
||||||
* Sets the PC to 0x0200 + Immediate operand
|
* Software Interrupt
|
||||||
*
|
* Pushes the flags register and the IP to the stack then
|
||||||
*
|
* Sets the IP to 0x0200 + 2*src.
|
||||||
|
* (x2 is to align with jmp instructions)
|
||||||
*
|
*
|
||||||
|
* No reserved interrupt vectors yet
|
||||||
*/
|
*/
|
||||||
public class IntInstruction extends Instruction{
|
public class IntInstruction extends Instruction{
|
||||||
|
|
||||||
|
@ -1,22 +1,28 @@
|
|||||||
package net.simon987.server.assembly.instruction;
|
package net.simon987.server.assembly.instruction;
|
||||||
|
|
||||||
import net.simon987.server.assembly.CPU;
|
import net.simon987.server.assembly.CPU;
|
||||||
|
|
||||||
import net.simon987.server.assembly.Instruction;
|
import net.simon987.server.assembly.Instruction;
|
||||||
import net.simon987.server.assembly.Status;
|
import net.simon987.server.assembly.Status;
|
||||||
|
|
||||||
public class IntrInstruction extends Instruction{
|
/**
|
||||||
|
* Interrupt Return
|
||||||
|
*
|
||||||
|
* Pops the IP and status flag from the stack.
|
||||||
|
*/
|
||||||
|
public class IretInstruction extends Instruction{
|
||||||
|
|
||||||
public static final int OPCODE = 49;
|
public static final int OPCODE = 49;
|
||||||
private CPU cpu;
|
private CPU cpu;
|
||||||
|
|
||||||
public IntrInstruction(CPU cpu) {
|
public IretInstruction(CPU cpu) {
|
||||||
super("intr", OPCODE);
|
super("intr", OPCODE);
|
||||||
this.cpu = cpu;
|
this.cpu = cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status execute(Status status) {
|
public Status execute(Status status) {
|
||||||
cpu.setIp((char)cpu.getMemory().get(cpu.getRegisterSet().getRegister("SP").getValue()));
|
cpu.setIp((char)cpu.getMemory().get(cpu.getRegisterSet().getRegister("SP").getValue())); //IP (SP + 0)
|
||||||
status.fromByte((char) cpu.getMemory().get(cpu.getRegisterSet().getRegister("SP").getValue() + 1));
|
status.fromByte((char) cpu.getMemory().get(cpu.getRegisterSet().getRegister("SP").getValue() + 1)); //Status (SP + 1)
|
||||||
cpu.getRegisterSet().getRegister("SP").setValue(cpu.getRegisterSet().getRegister("SP").getValue() + 2); //Increment SP (stack grows towards smaller)
|
cpu.getRegisterSet().getRegister("SP").setValue(cpu.getRegisterSet().getRegister("SP").getValue() + 2); //Increment SP (stack grows towards smaller)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user