From 29faa38e02b492ae82c3bdfa7d1c4ffbe69772cd Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 13 Oct 2025 02:22:11 -0400 Subject: emux64: cpu: Add emulation of SUB instruction Signed-off-by: Ian Moffett --- emux64/src/cpu/cpu_cycle.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/emux64/src/cpu/cpu_cycle.c b/emux64/src/cpu/cpu_cycle.c index b3a8987..663b300 100644 --- a/emux64/src/cpu/cpu_cycle.c +++ b/emux64/src/cpu/cpu_cycle.c @@ -207,6 +207,21 @@ cpu_do_add(struct osmx_core *core) } +static int +cpu_do_sub(struct osmx_core *core) +{ + struct arithop ops; + int error; + + error = cpu_arithop(core, &ops); + if (error < 0) { + return error; + } + + core->xn[ops.dest_reg] = ops.op1 - ops.op2; + return 0; +} + int cpu_run(struct osmx_core *core) { @@ -240,6 +255,12 @@ cpu_run(struct osmx_core *core) continue; } break; + case OP_SUB: + if (cpu_do_sub(core) < 0) { + core->run = false; + continue; + } + break; case OP_NOP: break; default: -- cgit v1.2.3