From 9f033845685adcb394615fbc12b077e9ded8ebca Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Sat, 24 Oct 2026 03:15:26 +0100 Subject: [PATCH] Fix 32-bit OR immediate handling and memory corruption --- cpu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpu.c b/cpu.c index ffe5602..abb8f60 100644 --- a/cpu.c +++ b/cpu.c @@ -2288,11 +2288,14 @@ fetch_instruction: } - case 0x0D: { /* OR AX, imm16 */ + case 0x0D: { /* OR AX/EAX, imm16/imm32 */ - uint16_t imm16 = fetch16 (cpu); /* Fetch the 16-bit immediate value */ + if (cpu->has_operand_override) { + set_reg32 (cpu, REG_AX, or32 (cpu, get_reg32 (cpu, REG_AX), fetch32 (cpu))); + } else { + cpu->regs[REG_AX] = or16 (cpu, cpu->regs[REG_AX], fetch16 (cpu)); + } - cpu->regs[REG_AX] = or16 (cpu, cpu->regs[REG_AX], imm16); /* Perform OR and update flags */ break; } -- 2.34.1