trunk/src/emu/cpu/i386/i386.h
| r243385 | r243386 | |
| 1187 | 1187 | void x87_fxtract(UINT8 modrm); |
| 1188 | 1188 | void x87_ftst(UINT8 modrm); |
| 1189 | 1189 | void x87_fxam(UINT8 modrm); |
| 1190 | void x87_fcmovb_sti(UINT8 modrm); |
| 1191 | void x87_fcmove_sti(UINT8 modrm); |
| 1192 | void x87_fcmovbe_sti(UINT8 modrm); |
| 1193 | void x87_fcmovu_sti(UINT8 modrm); |
| 1194 | void x87_fcmovnb_sti(UINT8 modrm); |
| 1195 | void x87_fcmovne_sti(UINT8 modrm); |
| 1196 | void x87_fcmovnbe_sti(UINT8 modrm); |
| 1197 | void x87_fcmovnu_sti(UINT8 modrm); |
| 1190 | 1198 | void x87_ficom_m16int(UINT8 modrm); |
| 1191 | 1199 | void x87_ficom_m32int(UINT8 modrm); |
| 1192 | 1200 | void x87_ficomp_m16int(UINT8 modrm); |
| r243385 | r243386 | |
| 1197 | 1205 | void x87_fcomp_m32real(UINT8 modrm); |
| 1198 | 1206 | void x87_fcomp_m64real(UINT8 modrm); |
| 1199 | 1207 | void x87_fcomp_sti(UINT8 modrm); |
| 1208 | void x87_fcomi_sti(UINT8 modrm); |
| 1200 | 1209 | void x87_fcomip_sti(UINT8 modrm); |
| 1210 | void x87_fucomi_sti(UINT8 modrm); |
| 1211 | void x87_fucomip_sti(UINT8 modrm); |
| 1201 | 1212 | void x87_fcompp(UINT8 modrm); |
| 1202 | 1213 | void x87_fucom_sti(UINT8 modrm); |
| 1203 | 1214 | void x87_fucomp_sti(UINT8 modrm); |
trunk/src/emu/cpu/i386/x87ops.inc
| r243385 | r243386 | |
| 115 | 115 | |
| 116 | 116 | extern flag floatx80_is_nan( floatx80 a ); |
| 117 | 117 | |
| 118 | extern flag floatx80_is_signaling_nan(floatx80 a); |
| 119 | |
| 120 | INLINE flag floatx80_is_quiet_nan(floatx80 a) |
| 121 | { |
| 122 | bits64 aLow; |
| 123 | |
| 124 | aLow = a.low & ~LIT64(0x4000000000000000); |
| 125 | return |
| 126 | ((a.high & 0x7FFF) == 0x7FFF) |
| 127 | && (bits64)(aLow << 1) |
| 128 | && (a.low != aLow); |
| 129 | } |
| 130 | |
| 118 | 131 | INLINE int floatx80_is_zero(floatx80 fx) |
| 119 | 132 | { |
| 120 | 133 | return (((fx.high & 0x7fff) == 0) && ((fx.low << 1) == 0)); |
| r243385 | r243386 | |
| 1957 | 1970 | CYCLES(22); |
| 1958 | 1971 | } |
| 1959 | 1972 | |
| 1973 | /************************************* |
| 1974 | * |
| 1975 | * Conditional Move |
| 1976 | * |
| 1977 | *************************************/ |
| 1960 | 1978 | |
| 1979 | void i386_device::x87_fcmovb_sti(UINT8 modrm) |
| 1980 | { |
| 1981 | floatx80 result; |
| 1982 | int i = modrm & 7; |
| 1983 | |
| 1984 | if (m_CF == 1) |
| 1985 | { |
| 1986 | if (X87_IS_ST_EMPTY(i)) |
| 1987 | { |
| 1988 | x87_set_stack_underflow(); |
| 1989 | result = fx80_inan; |
| 1990 | } |
| 1991 | else |
| 1992 | result = ST(i); |
| 1993 | |
| 1994 | if (x87_check_exceptions()) |
| 1995 | { |
| 1996 | ST(0) = result; |
| 1997 | } |
| 1998 | } |
| 1999 | |
| 2000 | CYCLES(4); |
| 2001 | } |
| 2002 | |
| 2003 | void i386_device::x87_fcmove_sti(UINT8 modrm) |
| 2004 | { |
| 2005 | floatx80 result; |
| 2006 | int i = modrm & 7; |
| 2007 | |
| 2008 | if (m_ZF == 1) |
| 2009 | { |
| 2010 | if (X87_IS_ST_EMPTY(i)) |
| 2011 | { |
| 2012 | x87_set_stack_underflow(); |
| 2013 | result = fx80_inan; |
| 2014 | } |
| 2015 | else |
| 2016 | result = ST(i); |
| 2017 | |
| 2018 | if (x87_check_exceptions()) |
| 2019 | { |
| 2020 | ST(0) = result; |
| 2021 | } |
| 2022 | } |
| 2023 | |
| 2024 | CYCLES(4); |
| 2025 | } |
| 2026 | |
| 2027 | void i386_device::x87_fcmovbe_sti(UINT8 modrm) |
| 2028 | { |
| 2029 | floatx80 result; |
| 2030 | int i = modrm & 7; |
| 2031 | |
| 2032 | if ((m_CF | m_ZF) == 1) |
| 2033 | { |
| 2034 | if (X87_IS_ST_EMPTY(i)) |
| 2035 | { |
| 2036 | x87_set_stack_underflow(); |
| 2037 | result = fx80_inan; |
| 2038 | } |
| 2039 | else |
| 2040 | result = ST(i); |
| 2041 | |
| 2042 | if (x87_check_exceptions()) |
| 2043 | { |
| 2044 | ST(0) = result; |
| 2045 | } |
| 2046 | } |
| 2047 | |
| 2048 | CYCLES(4); |
| 2049 | } |
| 2050 | |
| 2051 | void i386_device::x87_fcmovu_sti(UINT8 modrm) |
| 2052 | { |
| 2053 | floatx80 result; |
| 2054 | int i = modrm & 7; |
| 2055 | |
| 2056 | if (m_PF == 1) |
| 2057 | { |
| 2058 | if (X87_IS_ST_EMPTY(i)) |
| 2059 | { |
| 2060 | x87_set_stack_underflow(); |
| 2061 | result = fx80_inan; |
| 2062 | } |
| 2063 | else |
| 2064 | result = ST(i); |
| 2065 | |
| 2066 | if (x87_check_exceptions()) |
| 2067 | { |
| 2068 | ST(0) = result; |
| 2069 | } |
| 2070 | } |
| 2071 | |
| 2072 | CYCLES(4); |
| 2073 | } |
| 2074 | |
| 2075 | void i386_device::x87_fcmovnb_sti(UINT8 modrm) |
| 2076 | { |
| 2077 | floatx80 result; |
| 2078 | int i = modrm & 7; |
| 2079 | |
| 2080 | if (m_CF == 0) |
| 2081 | { |
| 2082 | if (X87_IS_ST_EMPTY(i)) |
| 2083 | { |
| 2084 | x87_set_stack_underflow(); |
| 2085 | result = fx80_inan; |
| 2086 | } |
| 2087 | else |
| 2088 | result = ST(i); |
| 2089 | |
| 2090 | if (x87_check_exceptions()) |
| 2091 | { |
| 2092 | ST(0) = result; |
| 2093 | } |
| 2094 | } |
| 2095 | |
| 2096 | CYCLES(4); |
| 2097 | } |
| 2098 | |
| 2099 | void i386_device::x87_fcmovne_sti(UINT8 modrm) |
| 2100 | { |
| 2101 | floatx80 result; |
| 2102 | int i = modrm & 7; |
| 2103 | |
| 2104 | if (m_ZF == 0) |
| 2105 | { |
| 2106 | if (X87_IS_ST_EMPTY(i)) |
| 2107 | { |
| 2108 | x87_set_stack_underflow(); |
| 2109 | result = fx80_inan; |
| 2110 | } |
| 2111 | else |
| 2112 | result = ST(i); |
| 2113 | |
| 2114 | if (x87_check_exceptions()) |
| 2115 | { |
| 2116 | ST(0) = result; |
| 2117 | } |
| 2118 | } |
| 2119 | |
| 2120 | CYCLES(4); |
| 2121 | } |
| 2122 | |
| 2123 | void i386_device::x87_fcmovnbe_sti(UINT8 modrm) |
| 2124 | { |
| 2125 | floatx80 result; |
| 2126 | int i = modrm & 7; |
| 2127 | |
| 2128 | if ((m_CF == 0) && (m_ZF == 0)) |
| 2129 | { |
| 2130 | if (X87_IS_ST_EMPTY(i)) |
| 2131 | { |
| 2132 | x87_set_stack_underflow(); |
| 2133 | result = fx80_inan; |
| 2134 | } |
| 2135 | else |
| 2136 | result = ST(i); |
| 2137 | |
| 2138 | if (x87_check_exceptions()) |
| 2139 | { |
| 2140 | ST(0) = result; |
| 2141 | } |
| 2142 | } |
| 2143 | |
| 2144 | CYCLES(4); |
| 2145 | } |
| 2146 | |
| 2147 | void i386_device::x87_fcmovnu_sti(UINT8 modrm) |
| 2148 | { |
| 2149 | floatx80 result; |
| 2150 | int i = modrm & 7; |
| 2151 | |
| 2152 | if (m_PF == 0) |
| 2153 | { |
| 2154 | if (X87_IS_ST_EMPTY(i)) |
| 2155 | { |
| 2156 | x87_set_stack_underflow(); |
| 2157 | result = fx80_inan; |
| 2158 | } |
| 2159 | else |
| 2160 | result = ST(i); |
| 2161 | |
| 2162 | if (x87_check_exceptions()) |
| 2163 | { |
| 2164 | ST(0) = result; |
| 2165 | } |
| 2166 | } |
| 2167 | |
| 2168 | CYCLES(4); |
| 2169 | } |
| 2170 | |
| 1961 | 2171 | /************************************* |
| 1962 | 2172 | * |
| 1963 | 2173 | * Miscellaneous arithmetic |
| r243385 | r243386 | |
| 3764 | 3974 | CYCLES(4); |
| 3765 | 3975 | } |
| 3766 | 3976 | |
| 3977 | void i386_device::x87_fcomi_sti(UINT8 modrm) |
| 3978 | { |
| 3979 | int i = modrm & 7; |
| 3980 | |
| 3981 | if (X87_IS_ST_EMPTY(0) || X87_IS_ST_EMPTY(i)) |
| 3982 | { |
| 3983 | x87_set_stack_underflow(); |
| 3984 | m_ZF = 1; |
| 3985 | m_PF = 1; |
| 3986 | m_CF = 1; |
| 3987 | } |
| 3988 | else |
| 3989 | { |
| 3990 | m_x87_sw &= ~X87_SW_C1; |
| 3991 | |
| 3992 | floatx80 a = ST(0); |
| 3993 | floatx80 b = ST(i); |
| 3994 | |
| 3995 | if (floatx80_is_nan(a) || floatx80_is_nan(b)) |
| 3996 | { |
| 3997 | m_ZF = 1; |
| 3998 | m_PF = 1; |
| 3999 | m_CF = 1; |
| 4000 | m_x87_sw |= X87_SW_IE; |
| 4001 | } |
| 4002 | else |
| 4003 | { |
| 4004 | m_ZF = 0; |
| 4005 | m_PF = 0; |
| 4006 | m_CF = 0; |
| 4007 | |
| 4008 | if (floatx80_eq(a, b)) |
| 4009 | m_ZF = 1; |
| 4010 | |
| 4011 | if (floatx80_lt(a, b)) |
| 4012 | m_CF = 1; |
| 4013 | } |
| 4014 | } |
| 4015 | |
| 4016 | x87_check_exceptions(); |
| 4017 | |
| 4018 | CYCLES(4); // TODO: correct cycle count |
| 4019 | } |
| 4020 | |
| 3767 | 4021 | void i386_device::x87_fcomip_sti(UINT8 modrm) |
| 3768 | 4022 | { |
| 3769 | 4023 | int i = modrm & 7; |
| r243385 | r243386 | |
| 3809 | 4063 | CYCLES(4); // TODO: correct cycle count |
| 3810 | 4064 | } |
| 3811 | 4065 | |
| 4066 | void i386_device::x87_fucomi_sti(UINT8 modrm) |
| 4067 | { |
| 4068 | int i = modrm & 7; |
| 4069 | |
| 4070 | if (X87_IS_ST_EMPTY(0) || X87_IS_ST_EMPTY(i)) |
| 4071 | { |
| 4072 | x87_set_stack_underflow(); |
| 4073 | m_ZF = 1; |
| 4074 | m_PF = 1; |
| 4075 | m_CF = 1; |
| 4076 | } |
| 4077 | else |
| 4078 | { |
| 4079 | m_x87_sw &= ~X87_SW_C1; |
| 4080 | |
| 4081 | floatx80 a = ST(0); |
| 4082 | floatx80 b = ST(i); |
| 4083 | |
| 4084 | if (floatx80_is_quiet_nan(a) || floatx80_is_quiet_nan(b)) |
| 4085 | { |
| 4086 | m_ZF = 1; |
| 4087 | m_PF = 1; |
| 4088 | m_CF = 1; |
| 4089 | } |
| 4090 | else if (floatx80_is_nan(a) || floatx80_is_nan(b)) |
| 4091 | { |
| 4092 | m_ZF = 1; |
| 4093 | m_PF = 1; |
| 4094 | m_CF = 1; |
| 4095 | m_x87_sw |= X87_SW_IE; |
| 4096 | } |
| 4097 | else |
| 4098 | { |
| 4099 | m_ZF = 0; |
| 4100 | m_PF = 0; |
| 4101 | m_CF = 0; |
| 4102 | |
| 4103 | if (floatx80_eq(a, b)) |
| 4104 | m_ZF = 1; |
| 4105 | |
| 4106 | if (floatx80_lt(a, b)) |
| 4107 | m_CF = 1; |
| 4108 | } |
| 4109 | } |
| 4110 | |
| 4111 | x87_check_exceptions(); |
| 4112 | |
| 4113 | CYCLES(4); // TODO: correct cycle count |
| 4114 | } |
| 4115 | |
| 4116 | void i386_device::x87_fucomip_sti(UINT8 modrm) |
| 4117 | { |
| 4118 | int i = modrm & 7; |
| 4119 | |
| 4120 | if (X87_IS_ST_EMPTY(0) || X87_IS_ST_EMPTY(i)) |
| 4121 | { |
| 4122 | x87_set_stack_underflow(); |
| 4123 | m_ZF = 1; |
| 4124 | m_PF = 1; |
| 4125 | m_CF = 1; |
| 4126 | } |
| 4127 | else |
| 4128 | { |
| 4129 | m_x87_sw &= ~X87_SW_C1; |
| 4130 | |
| 4131 | floatx80 a = ST(0); |
| 4132 | floatx80 b = ST(i); |
| 4133 | |
| 4134 | if (floatx80_is_quiet_nan(a) || floatx80_is_quiet_nan(b)) |
| 4135 | { |
| 4136 | m_ZF = 1; |
| 4137 | m_PF = 1; |
| 4138 | m_CF = 1; |
| 4139 | } |
| 4140 | else if (floatx80_is_nan(a) || floatx80_is_nan(b)) |
| 4141 | { |
| 4142 | m_ZF = 1; |
| 4143 | m_PF = 1; |
| 4144 | m_CF = 1; |
| 4145 | m_x87_sw |= X87_SW_IE; |
| 4146 | } |
| 4147 | else |
| 4148 | { |
| 4149 | m_ZF = 0; |
| 4150 | m_PF = 0; |
| 4151 | m_CF = 0; |
| 4152 | |
| 4153 | if (floatx80_eq(a, b)) |
| 4154 | m_ZF = 1; |
| 4155 | |
| 4156 | if (floatx80_lt(a, b)) |
| 4157 | m_CF = 1; |
| 4158 | } |
| 4159 | } |
| 4160 | |
| 4161 | if (x87_check_exceptions()) |
| 4162 | x87_inc_stack(); |
| 4163 | |
| 4164 | CYCLES(4); // TODO: correct cycle count |
| 4165 | } |
| 4166 | |
| 3812 | 4167 | void i386_device::x87_fcompp(UINT8 modrm) |
| 3813 | 4168 | { |
| 3814 | 4169 | if (X87_IS_ST_EMPTY(0) || X87_IS_ST_EMPTY(1)) |
| r243385 | r243386 | |
| 4508 | 4863 | { |
| 4509 | 4864 | switch (modrm) |
| 4510 | 4865 | { |
| 4511 | | case 0xe9: ptr = &i386_device::x87_fucompp; break; |
| 4866 | case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc4: case 0xc5: case 0xc6: case 0xc7: ptr = &i386_device::x87_fcmovb_sti; break; |
| 4867 | case 0xc8: case 0xc9: case 0xca: case 0xcb: case 0xcc: case 0xcd: case 0xce: case 0xcf: ptr = &i386_device::x87_fcmove_sti; break; |
| 4868 | case 0xd0: case 0xd1: case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: case 0xd7: ptr = &i386_device::x87_fcmovbe_sti; break; |
| 4869 | case 0xd8: case 0xd9: case 0xda: case 0xdb: case 0xdc: case 0xdd: case 0xde: case 0xdf: ptr = &i386_device::x87_fcmovu_sti; break; |
| 4870 | case 0xe9: ptr = &i386_device::x87_fucompp; break; |
| 4512 | 4871 | } |
| 4513 | 4872 | } |
| 4514 | 4873 | |
| r243385 | r243386 | |
| 4540 | 4899 | { |
| 4541 | 4900 | switch (modrm) |
| 4542 | 4901 | { |
| 4902 | case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc4: case 0xc5: case 0xc6: case 0xc7: ptr = &i386_device::x87_fcmovnb_sti; break; |
| 4903 | case 0xc8: case 0xc9: case 0xca: case 0xcb: case 0xcc: case 0xcd: case 0xce: case 0xcf: ptr = &i386_device::x87_fcmovne_sti; break; |
| 4904 | case 0xd0: case 0xd1: case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: case 0xd7: ptr = &i386_device::x87_fcmovnbe_sti; break; |
| 4905 | case 0xd8: case 0xd9: case 0xda: case 0xdb: case 0xdc: case 0xdd: case 0xde: case 0xdf: ptr = &i386_device::x87_fcmovnu_sti; break; |
| 4543 | 4906 | case 0xe0: ptr = &i386_device::x87_fnop; break; /* FENI */ |
| 4544 | 4907 | case 0xe1: ptr = &i386_device::x87_fnop; break; /* FDISI */ |
| 4545 | 4908 | case 0xe2: ptr = &i386_device::x87_fclex; break; |
| 4546 | 4909 | case 0xe3: ptr = &i386_device::x87_finit; break; |
| 4547 | 4910 | case 0xe4: ptr = &i386_device::x87_fnop; break; /* FSETPM */ |
| 4911 | case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee: case 0xef: ptr = &i386_device::x87_fucomi_sti; break; |
| 4912 | case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7: ptr = &i386_device::x87_fcomi_sti; break; |
| 4548 | 4913 | } |
| 4549 | 4914 | } |
| 4550 | 4915 | |
| r243385 | r243386 | |
| 4698 | 5063 | switch (modrm) |
| 4699 | 5064 | { |
| 4700 | 5065 | case 0xe0: ptr = &i386_device::x87_fstsw_ax; break; |
| 5066 | case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee: case 0xef: ptr = &i386_device::x87_fucomip_sti; break; |
| 4701 | 5067 | case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7: ptr = &i386_device::x87_fcomip_sti; break; |
| 4702 | 5068 | } |
| 4703 | 5069 | } |