summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author arbee <rb6502@users.noreply.github.com>2026-05-14 08:46:11 -0400
committer arbee <rb6502@users.noreply.github.com>2026-05-14 08:46:11 -0400
commitfc622d98e8a4b61092cdd5cd0852e8217de9798d (patch)
tree5020529bfc2923fba8efd340d54ee93f5d8856da
parent3d11b5a17de05ea08f718a3a35192940a2c6c919 (diff)
i86/i86.cpp: Emulate undocumented DIV/IDIV behavior for the 80(1)8x as relied on by mpc60. [R. Belmont]
-rw-r--r--src/devices/cpu/i86/i86.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/devices/cpu/i86/i86.cpp b/src/devices/cpu/i86/i86.cpp
index c30eecd6199..0fabeacbdf2 100644
--- a/src/devices/cpu/i86/i86.cpp
+++ b/src/devices/cpu/i86/i86.cpp
@@ -2,12 +2,25 @@
// copyright-holders:Carl
/****************************************************************************
- NEC V20/V30/V33 emulator modified back to a 8086/80186 emulator
-
- (Re)Written June-September 2000 by Bryan McPhail (mish@tendril.co.uk) based
- on code by Oliver Bergmann (Raul_Bloodworth@hotmail.com) who based code
- on the i286 emulator by Fabrice Frances which had initial work based on
- David Hedley's pcemu(!).
+ NEC V20/V30/V33 emulator modified back to a 8086/80186 emulator
+
+ (Re)Written June-September 2000 by Bryan McPhail (mish@tendril.co.uk) based
+ on code by Oliver Bergmann (Raul_Bloodworth@hotmail.com) who based code
+ on the i286 emulator by Fabrice Frances which had initial work based on
+ David Hedley's pcemu(!).
+
+ DIV/IDIV note: it's been observed on real 8086/8088 that DIV and IDIV
+ set the zero flag in the expected manner according to the quotient. The
+ firmware for the Akai MPC60 expicitly relies on this behavior. One
+ example from the routine that calculates how many timer ticks a sample
+ should play for:
+
+ 5659 sub dx,dx ; sets ZF=1
+ 565b mov cx,0x000a ; flags unchanged
+ 565e div cx ; firmware expects this to affect ZF
+ 5660 jne 0x5665
+ 5662 mov ax,1 ; if ZF=1 the quotient was zero, round up to 1 tick
+ 5665 ...
****************************************************************************/
@@ -2286,6 +2299,7 @@ bool i8086_common_cpu_device::common_op(uint8_t op)
{
m_regs.b[AL] = uresult;
m_regs.b[AH] = uresult2;
+ set_ZF(m_regs.b[AL]);
}
}
else
@@ -2309,6 +2323,7 @@ bool i8086_common_cpu_device::common_op(uint8_t op)
{
m_regs.b[AL] = result;
m_regs.b[AH] = result2;
+ set_ZF(m_regs.b[AL]);
}
}
else
@@ -2381,6 +2396,7 @@ bool i8086_common_cpu_device::common_op(uint8_t op)
{
m_regs.w[AX] = uresult;
m_regs.w[DX] = uresult2;
+ set_ZF(m_regs.w[AX]);
}
}
else
@@ -2404,6 +2420,7 @@ bool i8086_common_cpu_device::common_op(uint8_t op)
{
m_regs.w[AX] = result;
m_regs.w[DX] = result2;
+ set_ZF(m_regs.w[AX]);
}
}
else