mirror of
https://github.com/holub/mame
synced 2025-06-07 05:13:46 +03:00
i386: use floatx80_scale for fscale (nw)
This commit is contained in:
parent
873547cea2
commit
e5b13284bc
@ -3312,27 +3312,7 @@ void i386_device::x87_fscale(uint8_t modrm)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_x87_sw &= ~X87_SW_C1;
|
m_x87_sw &= ~X87_SW_C1;
|
||||||
value = ST(0);
|
value = floatx80_scale(ST(0), ST(1));
|
||||||
|
|
||||||
// Set the rounding mode to truncate
|
|
||||||
uint16_t old_cw = m_x87_cw;
|
|
||||||
uint16_t new_cw = (old_cw & ~(X87_CW_RC_MASK << X87_CW_RC_SHIFT)) | (X87_CW_RC_ZERO << X87_CW_RC_SHIFT);
|
|
||||||
x87_write_cw(new_cw);
|
|
||||||
|
|
||||||
// Interpret ST(1) as an integer
|
|
||||||
uint32_t st1 = floatx80_to_int32(floatx80_round_to_int(ST(1)));
|
|
||||||
|
|
||||||
// Restore the rounding mode
|
|
||||||
x87_write_cw(old_cw);
|
|
||||||
|
|
||||||
// Get the unbiased exponent of ST(0)
|
|
||||||
int16_t exp = (ST(0).high & 0x7fff) - 0x3fff;
|
|
||||||
|
|
||||||
// Calculate the new exponent
|
|
||||||
exp = (exp + st1 + 0x3fff) & 0x7fff;
|
|
||||||
|
|
||||||
// Write it back
|
|
||||||
value.high = (value.high & ~0x7fff) + exp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x87_check_exceptions())
|
if (x87_check_exceptions())
|
||||||
|
@ -3415,27 +3415,7 @@ void i8087_device::fscale(u8 modrm)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sw &= ~X87_SW_C1;
|
m_sw &= ~X87_SW_C1;
|
||||||
value = ST(0);
|
value = floatx80_scale(ST(0), ST(1));
|
||||||
|
|
||||||
// Set the rounding mode to truncate
|
|
||||||
u16 old_cw = m_cw;
|
|
||||||
u16 new_cw = (old_cw & ~(X87_CW_RC_MASK << X87_CW_RC_SHIFT)) | (X87_CW_RC_ZERO << X87_CW_RC_SHIFT);
|
|
||||||
write_cw(new_cw);
|
|
||||||
|
|
||||||
// Interpret ST(1) as an integer
|
|
||||||
u32 st1 = floatx80_to_int32(floatx80_round_to_int(ST(1)));
|
|
||||||
|
|
||||||
// Restore the rounding mode
|
|
||||||
write_cw(old_cw);
|
|
||||||
|
|
||||||
// Get the unbiased exponent of ST(0)
|
|
||||||
int16_t exp = (ST(0).high & 0x7fff) - 0x3fff;
|
|
||||||
|
|
||||||
// Calculate the new exponent
|
|
||||||
exp = (exp + st1 + 0x3fff) & 0x7fff;
|
|
||||||
|
|
||||||
// Write it back
|
|
||||||
value.high = (value.high & ~0x7fff) + exp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_exceptions())
|
if (check_exceptions())
|
||||||
|
Loading…
Reference in New Issue
Block a user