From aca3a6d3ae9d853d5b5ac00068ae8e486bc61e25 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 27 Jul 2025 23:26:09 -0400 Subject: oemu: cpu: Add decoding for XOR instruction Signed-off-by: Ian Moffett --- usr.bin/oemu/cpu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'usr.bin') 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; -- cgit v1.2.3