diff options
author | Ian Moffett <ian@osmora.org> | 2025-07-30 16:36:12 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-07-30 16:36:12 -0400 |
commit | e597f7d3ac8723fc1408ca724206492ab2cc78bb (patch) | |
tree | 3621f5abe4b321f00cc2b6bc4fa5f813515788f3 /usr.bin/oemu/cpu.c | |
parent | caa652ae2b3da86de945fa8d5ece55ddbbb2cf31 (diff) |
oemu: cpu: Add decoding for shiftinstruction
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oemu/cpu.c')
-rw-r--r-- | usr.bin/oemu/cpu.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/usr.bin/oemu/cpu.c b/usr.bin/oemu/cpu.c index 4aab553..de8b465 100644 --- a/usr.bin/oemu/cpu.c +++ b/usr.bin/oemu/cpu.c @@ -295,6 +295,31 @@ cpu_br(struct oemu_cpu *cpu, inst_t *inst) } /* + * Decode a logical shift instruction: + * + * LSR r, r/imm + * LSL r, r/imm + */ +static void +cpu_lshift(struct oemu_cpu *cpu, inst_t *inst) +{ + struct cpu_regs *regs = &cpu->regs; + reg_t reg = inst->rd; + imm_t shift = inst->imm; + + switch (inst->opcode) { + case INST_LSR: + regs->xreg[reg] >>= shift; + printf("X%d >> %d -> %d\n", reg, shift, regs->xreg[reg]); + break; + case INST_LSL: + regs->xreg[reg] <<= shift; + printf("X%d << %d -> %d\n", reg, shift, regs->xreg[reg]); + break; + } +} + +/* * Decode MRO type instructions */ static void @@ -463,6 +488,10 @@ cpu_kick(struct oemu_cpu *cpu, struct sysmem *mem) case INST_BR: cpu_br(cpu, inst); break; + case INST_LSL: + case INST_LSR: + cpu_lshift(cpu, inst); + break; default: if (cpu_is_mro(inst)) { cpu_mro(cpu, inst); |