From: Robert Pengelly Date: Thu, 29 Oct 2026 09:33:49 +0000 (+0000) Subject: Implement F6 /7 signed 8-bit division X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=57b00ee97585b76a6c2aa5ebdd1b2b39984fdfec;p=dosemu.git Implement F6 /7 signed 8-bit division --- diff --git a/cpu.c b/cpu.c index f1de6d1..df19d6b 100644 --- a/cpu.c +++ b/cpu.c @@ -8897,6 +8897,42 @@ fetch_instruction: } + case 7: { /* IDIV rm8 (Signed AX / rm8) */ + + int16_t dividend = (int16_t) cpu->regs[REG_AX]; + int8_t divisor = (int8_t) operand_read8 (cpu, &rm); + int32_t quotient, remainder; + + if (!divisor) { + + if (cpu_divide_error (cpu, (uint32_t) old_ip) != 0) { + return -1; + } + + break; + + } + + quotient = dividend / divisor; + remainder = dividend % divisor; + + if (quotient > 127 || quotient < -128) { + + if (cpu_divide_error (cpu, (uint32_t) old_ip) != 0) { + return -1; + } + + break; + + } + + set_reg8 (cpu, 0, (uint8_t) quotient); /* AL */ + set_reg8 (cpu, 4, (uint8_t) remainder); /* AH */ + + break; + + } + default: fprintf (stderr, "F6 Subop /%d not implemented\n", subop);