|
@@ -32,7 +32,7 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
commands.add(SPS_A_INPUT);
|
|
|
commands.add(SPS_A_CALCULATE);
|
|
|
commands.add(SPS_PAGE);
|
|
|
- commands.add(SPS_JUMP_UP);
|
|
|
+ commands.add(SPS_JUMP);
|
|
|
commands.add(SPS_C_LOOP);
|
|
|
commands.add(SPS_D_LOOP);
|
|
|
commands.add(SPS_SKIP_IF);
|
|
@@ -424,11 +424,11 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static SPSCommand SPS_JUMP_UP = new SPSCommandImpl().setName("Jump").setMnemonic("JMP")
|
|
|
+ private static SPSCommand SPS_JUMP = new SPSCommandImpl().setName("Jump").setMnemonic("JMP")
|
|
|
.setCommandByte((byte) 0x90);
|
|
|
static {
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
- SPS_JUMP_UP.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
+ SPS_JUMP.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
((HoltekEmulatorInternals) internals).address = getData()
|
|
@@ -436,7 +436,7 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("Jump " + Integer.toString(i)).setMnemonic("JMP" + Integer.toString(i))
|
|
|
- .setCommandByte((byte) (SPS_JUMP_UP.getCommandByte() + i)).setCommand(SPS_JUMP_UP));
|
|
|
+ .setCommandByte((byte) (SPS_JUMP.getCommandByte() + i)).setCommand(SPS_JUMP));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -447,7 +447,16 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_C_LOOP.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ byte c = internals.getRegister(HoltekEmulatorInternals.REGISTER_C);
|
|
|
+ if (c > 0) {
|
|
|
+ c -= 1;
|
|
|
+ c = (byte) (c & 0x0F);
|
|
|
+ internals.setRegister(HoltekEmulatorInternals.REGISTER_C, c);
|
|
|
+ ((HoltekEmulatorInternals) internals).address = getData()
|
|
|
+ + (internals.getRegister(HoltekEmulatorInternals.REGISTER_PAGE) * 16);
|
|
|
+ } else {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("C* Loop " + Integer.toString(i)).setMnemonic("CLOP" + Integer.toString(i))
|
|
@@ -462,7 +471,16 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_D_LOOP.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ byte d = internals.getRegister(HoltekEmulatorInternals.REGISTER_D);
|
|
|
+ if (d > 0) {
|
|
|
+ d -= 1;
|
|
|
+ d = (byte) (d & 0x0F);
|
|
|
+ internals.setRegister(HoltekEmulatorInternals.REGISTER_D, d);
|
|
|
+ ((HoltekEmulatorInternals) internals).address = getData()
|
|
|
+ + (internals.getRegister(HoltekEmulatorInternals.REGISTER_PAGE) * 16);
|
|
|
+ } else {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("D* Loop " + Integer.toString(i)).setMnemonic("DLOP" + Integer.toString(i))
|
|
@@ -476,7 +494,12 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ byte a = internals.getRegister(HoltekEmulatorInternals.REGISTER_A);
|
|
|
+ byte b = internals.getRegister(HoltekEmulatorInternals.REGISTER_B);
|
|
|
+ if (a > b) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("A>B").setMnemonic("AGRB").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x01))
|
|
@@ -484,7 +507,12 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ byte a = internals.getRegister(HoltekEmulatorInternals.REGISTER_A);
|
|
|
+ byte b = internals.getRegister(HoltekEmulatorInternals.REGISTER_B);
|
|
|
+ if (a < b) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("A<B").setMnemonic("ASMB").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x02))
|
|
@@ -492,79 +520,56 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ byte a = internals.getRegister(HoltekEmulatorInternals.REGISTER_A);
|
|
|
+ byte b = internals.getRegister(HoltekEmulatorInternals.REGISTER_B);
|
|
|
+ if (a == b) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("A=B").setMnemonic("AEQB").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x03))
|
|
|
.setCommand(SPS_SKIP_IF));
|
|
|
+
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
+ @Override
|
|
|
+ public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
+ byte in = input.getInput();
|
|
|
+ byte data = (byte) (getData() - 0x04);
|
|
|
+ if ((in & (0x01 << data)) > 0) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
+ return output;
|
|
|
+ }
|
|
|
+ }.setName(String.format("In.%d=1", i + 1)).setMnemonic(String.format("IN%d1", i + 1))
|
|
|
+ .setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x04 + i)).setCommand(SPS_SKIP_IF));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
+ @Override
|
|
|
+ public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
+ byte in = input.getInput();
|
|
|
+ byte data = (byte) (getData() - 0x08);
|
|
|
+ if ((in & (0x01 << data)) == 0) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
+ return output;
|
|
|
+ }
|
|
|
+ }.setName(String.format("In.%d=0", i + 1)).setMnemonic(String.format("IN%d0", i + 1))
|
|
|
+ .setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x08 + i)).setCommand(SPS_SKIP_IF));
|
|
|
+ }
|
|
|
+
|
|
|
SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
- return output;
|
|
|
- }
|
|
|
- }.setName("In.1=1").setMnemonic("IN11").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x04))
|
|
|
- .setCommand(SPS_SKIP_IF));
|
|
|
- SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
- @Override
|
|
|
- public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
- return output;
|
|
|
- }
|
|
|
- }.setName("In.2=1").setMnemonic("IN21").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x05))
|
|
|
- .setCommand(SPS_SKIP_IF));
|
|
|
- SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
- @Override
|
|
|
- public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
- return output;
|
|
|
- }
|
|
|
- }.setName("In.3=1").setMnemonic("IN31").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x06))
|
|
|
- .setCommand(SPS_SKIP_IF));
|
|
|
- SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
- @Override
|
|
|
- public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
- return output;
|
|
|
- }
|
|
|
- }.setName("In.4=1").setMnemonic("IN41").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x07))
|
|
|
- .setCommand(SPS_SKIP_IF));
|
|
|
- SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
- @Override
|
|
|
- public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
- return output;
|
|
|
- }
|
|
|
- }.setName("In.1=0").setMnemonic("IN10").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x08))
|
|
|
- .setCommand(SPS_SKIP_IF));
|
|
|
- SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
- @Override
|
|
|
- public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
- return output;
|
|
|
- }
|
|
|
- }.setName("In.2=0").setMnemonic("IN20").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x09))
|
|
|
- .setCommand(SPS_SKIP_IF));
|
|
|
- SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
- @Override
|
|
|
- public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
- return output;
|
|
|
- }
|
|
|
- }.setName("In.3=0").setMnemonic("IN30").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x0A))
|
|
|
- .setCommand(SPS_SKIP_IF));
|
|
|
- SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
- @Override
|
|
|
- public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
- return output;
|
|
|
- }
|
|
|
- }.setName("In.4=0").setMnemonic("IN40").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x0B))
|
|
|
- .setCommand(SPS_SKIP_IF));
|
|
|
- SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
- @Override
|
|
|
- public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ if (!input.getFeatureAsBool(HoltekEmulatorInput.S1)) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("S1=0").setMnemonic("S10").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x0C))
|
|
@@ -572,7 +577,10 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ if (!input.getFeatureAsBool(HoltekEmulatorInput.S2)) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("S2=0").setMnemonic("S20").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x0D))
|
|
@@ -580,7 +588,10 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ if (input.getFeatureAsBool(HoltekEmulatorInput.S1)) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("S1=1").setMnemonic("S11").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x0E))
|
|
@@ -588,7 +599,10 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_SKIP_IF.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ if (input.getFeatureAsBool(HoltekEmulatorInput.S2)) {
|
|
|
+ internals.incAddress(1);
|
|
|
+ }
|
|
|
+ internals.incAddress(1);
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("S2=1").setMnemonic("S21").setCommandByte((byte) (SPS_SKIP_IF.getCommandByte() + 0x0F))
|
|
@@ -602,7 +616,9 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_CALL.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ internals.pushRtrAddress();
|
|
|
+ ((HoltekEmulatorInternals) internals).address = getData()
|
|
|
+ + (internals.getRegister(HoltekEmulatorInternals.REGISTER_PAGE) * 16);
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("Call " + Integer.toString(i)).setMnemonic("CALL" + Integer.toString(i))
|
|
@@ -617,7 +633,7 @@ public class HoltekEmulator extends AbstractEmulator implements SPSEmulator {
|
|
|
SPS_RETURN.getCommandDatas().add(new SPSCommandDataImpl() {
|
|
|
@Override
|
|
|
public EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output) {
|
|
|
- ((HoltekEmulatorInternals) internals).address++;
|
|
|
+ internals.popRtrAddress();
|
|
|
return output;
|
|
|
}
|
|
|
}.setName("Return").setMnemonic("RET").setCommandByte((byte) (SPS_RETURN.getCommandByte())).setCommand(SPS_RETURN));
|