diff options
author | Ian Moffett <ian@osmora.org> | 2025-07-27 23:04:39 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-07-28 03:31:01 -0400 |
commit | 5e746b367abd36c3057130940dfad61636f5e925 (patch) | |
tree | 4583ca501c67c6c8b20a1e1d9475af0a1d38adf2 /usr.bin | |
parent | a4a7080dee359ca95f09d91d68d1d8c4a1f59cd6 (diff) |
oemu: cpu: Add decoding for AND instruction
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/oemu/cpu.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.bin/oemu/cpu.c b/usr.bin/oemu/cpu.c index 49d4671..f3b6a23 100644 --- a/usr.bin/oemu/cpu.c +++ b/usr.bin/oemu/cpu.c @@ -187,6 +187,22 @@ cpu_mul(struct oemu_cpu *cpu, inst_t *inst) printf("%d * %d -> X%d, new=%d\n", imm, inst->imm, inst->rd, regs->xreg[inst->rd]); } +static void +cpu_and(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 'and'\n"); + return; + } + + imm = inst->imm; + regs->xreg[inst->rd] &= inst->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 @@ -335,7 +351,6 @@ cpu_reset(struct oemu_cpu *cpu) regs->ilr = 0x0; memset(regs->xreg, 0x0, sizeof(regs->xreg)); } - void cpu_regdump(struct oemu_cpu *cpu) { @@ -402,6 +417,9 @@ cpu_kick(struct oemu_cpu *cpu, struct sysmem *mem) case INST_DIV: cpu_div(cpu, inst); break; + case INST_AND: + cpu_and(cpu, inst); + break; case INST_BR: cpu_br(cpu, inst); break; |