mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-10 14:26:45 +00:00
Added JA and JNA Instructions
This commit is contained in:
parent
c772abe0bf
commit
8d961ce572
@ -99,6 +99,8 @@ public class CPU implements MongoSerialisable {
|
||||
instructionSet.add(new JoInstruction(this));
|
||||
instructionSet.add(new PushfInstruction(this));
|
||||
instructionSet.add(new PopfInstruction(this));
|
||||
instructionSet.add(new JnaInstruction(this));
|
||||
instructionSet.add(new JaInstruction(this));
|
||||
|
||||
status = new Status();
|
||||
memory = new Memory(config.getInt("memory_size"));
|
||||
|
@ -0,0 +1,38 @@
|
||||
package net.simon987.server.assembly.instruction;
|
||||
|
||||
import net.simon987.server.assembly.CPU;
|
||||
import net.simon987.server.assembly.Instruction;
|
||||
import net.simon987.server.assembly.Status;
|
||||
import net.simon987.server.assembly.Target;
|
||||
|
||||
/**
|
||||
* Jump if above
|
||||
*/
|
||||
public class JaInstruction extends Instruction {
|
||||
|
||||
public static final int OPCODE = 46;
|
||||
|
||||
private CPU cpu;
|
||||
|
||||
public JaInstruction(CPU cpu) {
|
||||
super("ja", OPCODE);
|
||||
|
||||
this.cpu = cpu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status execute(Target src, int srcIndex, Status status) {
|
||||
if (!status.isCarryFlag() && !status.isZeroFlag()) {
|
||||
cpu.setIp((char) src.get(srcIndex));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status execute(int src, Status status) {
|
||||
if (!status.isCarryFlag() && !status.isZeroFlag()) {
|
||||
cpu.setIp((char) src);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.simon987.server.assembly.instruction;
|
||||
|
||||
import net.simon987.server.assembly.CPU;
|
||||
import net.simon987.server.assembly.Instruction;
|
||||
import net.simon987.server.assembly.Status;
|
||||
import net.simon987.server.assembly.Target;
|
||||
|
||||
/**
|
||||
* Jump if not above
|
||||
*/
|
||||
public class JnaInstruction extends Instruction {
|
||||
|
||||
public static final int OPCODE = 47;
|
||||
|
||||
private CPU cpu;
|
||||
|
||||
public JnaInstruction(CPU cpu) {
|
||||
super("jna", OPCODE);
|
||||
|
||||
this.cpu = cpu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status execute(Target src, int srcIndex, Status status) {
|
||||
if (status.isCarryFlag() || status.isZeroFlag()) {
|
||||
cpu.setIp((char) src.get(srcIndex));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status execute(int src, Status status) {
|
||||
if (status.isCarryFlag() || status.isZeroFlag()) {
|
||||
cpu.setIp((char) src);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user