summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-27 23:26:09 -0400
committerIan Moffett <ian@osmora.org>2025-07-28 03:31:14 -0400
commitaca3a6d3ae9d853d5b5ac00068ae8e486bc61e25 (patch)
treee33da9f958c119b5f7a7426f5caa2445f1c79a8a /usr.bin
parent0d5a742b653870e742b3565389743bbccb39851d (diff)
oemu: cpu: Add decoding for XOR instruction
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/oemu/cpu.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/usr.bin/oemu/cpu.c b/usr.bin/oemu/cpu.c
index 709cf0e..4aab553 100644
--- a/usr.bin/oemu/cpu.c
+++ b/usr.bin/oemu/cpu.c
@@ -221,6 +221,23 @@ cpu_or(struct oemu_cpu *cpu, inst_t *inst)
inst->rd, inst->imm, inst->rd, regs->xreg[inst->rd]);
}
+static void
+cpu_xor(struct oemu_cpu *cpu, inst_t *inst)
+{
+ struct cpu_regs *regs = &cpu->regs;
+ imm_t imm;
+
+ if (inst->rd > NELEM(regs->xreg)) {
+ printf("bad register operand for 'xor'\n");
+ return;
+ }
+
+ imm = inst->imm;
+ regs->xreg[inst->rd] ^= imm;
+ printf("X%d ^ %x -> X%d, new=%d\n",
+ inst->rd, inst->imm, inst->rd, regs->xreg[inst->rd]);
+}
+
/*
* Decode the INST_DIV instruction
*
@@ -440,6 +457,9 @@ cpu_kick(struct oemu_cpu *cpu, struct sysmem *mem)
case INST_OR:
cpu_or(cpu, inst);
break;
+ case INST_XOR:
+ cpu_xor(cpu, inst);
+ break;
case INST_BR:
cpu_br(cpu, inst);
break;