diff options
| author | 2026-05-01 22:01:04 -0500 | |
|---|---|---|
| committer | 2026-05-01 22:01:04 -0500 | |
| commit | 67b67f83d7be409132832611ecdf191dbd4e7d01 (patch) | |
| tree | 3e3abc5927d57217416a68b21a517ae678d853c9 /src | |
| parent | 8945f05060c1ea53fb2c56bc8408242c42c99b92 (diff) | |
i8087: fix fprem1
Diffstat (limited to 'src')
| -rw-r--r-- | src/devices/cpu/i386/x87ops.hxx | 16 | ||||
| -rw-r--r-- | src/devices/machine/i8087.cpp | 16 |
2 files changed, 24 insertions, 8 deletions
diff --git a/src/devices/cpu/i386/x87ops.hxx b/src/devices/cpu/i386/x87ops.hxx index 374697227a4..a9c53159642 100644 --- a/src/devices/cpu/i386/x87ops.hxx +++ b/src/devices/cpu/i386/x87ops.hxx @@ -2303,13 +2303,21 @@ void i386_device::x87_fprem1(uint8_t modrm) } else { - extFloat80_t a = ST(0); - extFloat80_t b = ST(1); + uint64_t q; m_x87_sw &= ~X87_SW_C2; - // TODO: Implement Cx bits - result = extF80_rem(a, b); + if (!extFloat80_ieee754_remainder(ST(0), ST(1), result, q)) { + m_x87_sw &= ~(X87_SW_C0|X87_SW_C3|X87_SW_C1); + if (q & 1) + m_x87_sw |= X87_SW_C1; + if (q & 2) + m_x87_sw |= X87_SW_C3; + if (q & 4) + m_x87_sw |= X87_SW_C0; + } + else + m_x87_sw |= X87_SW_C2; } if (x87_check_exceptions()) diff --git a/src/devices/machine/i8087.cpp b/src/devices/machine/i8087.cpp index b8dc0fbd4f5..ffa18dfb4d4 100644 --- a/src/devices/machine/i8087.cpp +++ b/src/devices/machine/i8087.cpp @@ -2137,13 +2137,21 @@ void i8087_device::fprem1(u8 modrm) } else { - extFloat80_t a = ST(0); - extFloat80_t b = ST(1); + uint64_t q; m_sw &= ~X87_SW_C2; - // TODO: Implement Cx bits - result = extF80_rem(a, b); + if (!extFloat80_ieee754_remainder(ST(0), ST(1), result, q)) { + m_sw &= ~(X87_SW_C0|X87_SW_C3|X87_SW_C1); + if (q & 1) + m_sw |= X87_SW_C1; + if (q & 2) + m_sw |= X87_SW_C3; + if (q & 4) + m_sw |= X87_SW_C0; + } + else + m_sw |= X87_SW_C2; } if (check_exceptions()) |
