PCem
changeset 167:1dda97300a32
Further fixes to IMUL flags.
| author | TomW |
|---|---|
| date | Thu Oct 02 19:52:56 2014 +0100 |
| parents | 096e27a8c67b |
| children | 2d3db7fa48ab |
| files | src/x86_ops_misc.h src/x86_ops_mul.h |
| diffstat | 2 files changed, 46 insertions(+), 46 deletions(-) [+] |
line diff
1.1 --- a/src/x86_ops_misc.h Sun Sep 28 11:48:52 2014 +0100 1.2 +++ b/src/x86_ops_misc.h Thu Oct 02 19:52:56 2014 +0100 1.3 @@ -75,8 +75,8 @@ 1.4 tempws = (int)((int8_t)AL) * (int)((int8_t)dst); 1.5 AX = tempws & 0xffff; 1.6 flags_rebuild(); 1.7 - if (AH && AH != 0xff) flags |= (C_FLAG | V_FLAG); 1.8 - else flags &= ~(C_FLAG | V_FLAG); 1.9 + if (((int16_t)AX >> 7) != 0 && ((int16_t)AX >> 7) != -1) flags |= (C_FLAG | V_FLAG); 1.10 + else flags &= ~(C_FLAG | V_FLAG); 1.11 cycles -= 14; 1.12 break; 1.13 case 0x30: /*DIV AL,b*/ 1.14 @@ -163,8 +163,8 @@ 1.15 tempws = (int)((int8_t)AL) * (int)((int8_t)dst); 1.16 AX = tempws & 0xffff; 1.17 flags_rebuild(); 1.18 - if (AH && AH != 0xff) flags |= (C_FLAG | V_FLAG); 1.19 - else flags &= ~(C_FLAG | V_FLAG); 1.20 + if (((int16_t)AX >> 7) != 0 && ((int16_t)AX >> 7) != -1) flags |= (C_FLAG | V_FLAG); 1.21 + else flags &= ~(C_FLAG | V_FLAG); 1.22 cycles -= 14; 1.23 break; 1.24 case 0x30: /*DIV AL,b*/ 1.25 @@ -257,8 +257,8 @@ 1.26 AX = templ & 0xFFFF; 1.27 DX = templ >> 16; 1.28 flags_rebuild(); 1.29 - if (DX && DX != 0xFFFF) flags |= (C_FLAG | V_FLAG); 1.30 - else flags &= ~(C_FLAG | V_FLAG); 1.31 + if (((int32_t)templ >> 15) != 0 && ((int32_t)templ >> 15) != -1) flags |= (C_FLAG | V_FLAG); 1.32 + else flags &= ~(C_FLAG | V_FLAG); 1.33 cycles -= 22; 1.34 break; 1.35 case 0x30: /*DIV AX,w*/ 1.36 @@ -341,8 +341,8 @@ 1.37 AX = templ & 0xFFFF; 1.38 DX = templ >> 16; 1.39 flags_rebuild(); 1.40 - if (DX && DX != 0xFFFF) flags |= (C_FLAG | V_FLAG); 1.41 - else flags &= ~(C_FLAG | V_FLAG); 1.42 + if (((int32_t)templ >> 15) != 0 && ((int32_t)templ >> 15) != -1) flags |= (C_FLAG | V_FLAG); 1.43 + else flags &= ~(C_FLAG | V_FLAG); 1.44 cycles -= 22; 1.45 break; 1.46 case 0x30: /*DIV AX,w*/ 1.47 @@ -425,8 +425,8 @@ 1.48 EAX = temp64 & 0xffffffff; 1.49 EDX = temp64 >> 32; 1.50 flags_rebuild(); 1.51 - if (EDX && EDX != 0xffffffff) flags |= (C_FLAG|V_FLAG); 1.52 - else flags &= ~(C_FLAG|V_FLAG); 1.53 + if (((int64_t)temp64 >> 31) != 0 && ((int64_t)temp64 >> 31) != -1) flags |= (C_FLAG | V_FLAG); 1.54 + else flags &= ~(C_FLAG | V_FLAG); 1.55 cycles -= 38; 1.56 break; 1.57 case 0x30: /*DIV EAX,l*/ 1.58 @@ -485,8 +485,8 @@ 1.59 EAX = temp64 & 0xffffffff; 1.60 EDX = temp64 >> 32; 1.61 flags_rebuild(); 1.62 - if (EDX && EDX != 0xffffffff) flags |= (C_FLAG|V_FLAG); 1.63 - else flags &= ~(C_FLAG|V_FLAG); 1.64 + if (((int64_t)temp64 >> 31) != 0 && ((int64_t)temp64 >> 31) != -1) flags |= (C_FLAG | V_FLAG); 1.65 + else flags &= ~(C_FLAG | V_FLAG); 1.66 cycles -= 38; 1.67 break; 1.68 case 0x30: /*DIV EAX,l*/
2.1 --- a/src/x86_ops_mul.h Sun Sep 28 11:48:52 2014 +0100 2.2 +++ b/src/x86_ops_mul.h Thu Oct 02 19:52:56 2014 +0100 2.3 @@ -1,6 +1,6 @@ 2.4 static int opIMUL_w_iw_a16(uint32_t fetchdat) 2.5 { 2.6 - uint32_t templ; 2.7 + int32_t templ; 2.8 int16_t tempw, tempw2; 2.9 2.10 fetch_ea_16(fetchdat); 2.11 @@ -10,8 +10,8 @@ 2.12 2.13 templ = ((int)tempw) * ((int)tempw2); 2.14 flags_rebuild(); 2.15 - if ((templ >> 16) != 0 && (templ >> 16) != 0xffff) flags |= C_FLAG | V_FLAG; 2.16 - else flags &= ~(C_FLAG | V_FLAG); 2.17 + if ((templ >> 15) != 0 && (templ >> 15) != -1) flags |= C_FLAG | V_FLAG; 2.18 + else flags &= ~(C_FLAG | V_FLAG); 2.19 regs[reg].w = templ & 0xffff; 2.20 2.21 cycles -= (mod == 3) ? 14 : 17; 2.22 @@ -19,7 +19,7 @@ 2.23 } 2.24 static int opIMUL_w_iw_a32(uint32_t fetchdat) 2.25 { 2.26 - uint32_t templ; 2.27 + int32_t templ; 2.28 int16_t tempw, tempw2; 2.29 2.30 fetch_ea_32(fetchdat); 2.31 @@ -29,8 +29,8 @@ 2.32 2.33 templ = ((int)tempw) * ((int)tempw2); 2.34 flags_rebuild(); 2.35 - if ((templ >> 16) != 0 && (templ >> 16) != 0xffff) flags |= C_FLAG | V_FLAG; 2.36 - else flags &= ~(C_FLAG | V_FLAG); 2.37 + if ((templ >> 15) != 0 && (templ >> 15) != -1) flags |= C_FLAG | V_FLAG; 2.38 + else flags &= ~(C_FLAG | V_FLAG); 2.39 regs[reg].w = templ & 0xffff; 2.40 2.41 cycles -= (mod == 3) ? 14 : 17; 2.42 @@ -49,8 +49,8 @@ 2.43 2.44 temp64 = ((int64_t)templ) * ((int64_t)templ2); 2.45 flags_rebuild(); 2.46 - if ((temp64 >> 32) != 0 && (temp64 >> 32) != 0xffffffff) flags |= C_FLAG | V_FLAG; 2.47 - else flags &= ~(C_FLAG | V_FLAG); 2.48 + if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) flags |= C_FLAG | V_FLAG; 2.49 + else flags &= ~(C_FLAG | V_FLAG); 2.50 regs[reg].l = temp64 & 0xffffffff; 2.51 2.52 cycles-=25; 2.53 @@ -68,8 +68,8 @@ 2.54 2.55 temp64 = ((int64_t)templ) * ((int64_t)templ2); 2.56 flags_rebuild(); 2.57 - if ((temp64 >> 32) != 0 && (temp64 >> 32) != 0xffffffff) flags |= C_FLAG | V_FLAG; 2.58 - else flags &= ~(C_FLAG | V_FLAG); 2.59 + if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) flags |= C_FLAG | V_FLAG; 2.60 + else flags &= ~(C_FLAG | V_FLAG); 2.61 regs[reg].l = temp64 & 0xffffffff; 2.62 2.63 cycles-=25; 2.64 @@ -78,7 +78,7 @@ 2.65 2.66 static int opIMUL_w_ib_a16(uint32_t fetchdat) 2.67 { 2.68 - uint32_t templ; 2.69 + int32_t templ; 2.70 int16_t tempw, tempw2; 2.71 2.72 fetch_ea_16(fetchdat); 2.73 @@ -89,8 +89,8 @@ 2.74 2.75 templ = ((int)tempw) * ((int)tempw2); 2.76 flags_rebuild(); 2.77 - if ((templ >> 16) != 0 && ((templ >> 16) & 0xffff) != 0xffff) flags |= C_FLAG | V_FLAG; 2.78 - else flags &= ~(C_FLAG | V_FLAG); 2.79 + if ((templ >> 15) != 0 && (templ >> 15) != -1) flags |= C_FLAG | V_FLAG; 2.80 + else flags &= ~(C_FLAG | V_FLAG); 2.81 regs[reg].w = templ & 0xffff; 2.82 2.83 cycles -= (mod == 3) ? 14 : 17; 2.84 @@ -98,7 +98,7 @@ 2.85 } 2.86 static int opIMUL_w_ib_a32(uint32_t fetchdat) 2.87 { 2.88 - uint32_t templ; 2.89 + int32_t templ; 2.90 int16_t tempw, tempw2; 2.91 2.92 fetch_ea_32(fetchdat); 2.93 @@ -109,8 +109,8 @@ 2.94 2.95 templ = ((int)tempw) * ((int)tempw2); 2.96 flags_rebuild(); 2.97 - if ((templ >> 16) != 0 && ((templ >> 16) & 0xffff) != 0xffff) flags |= C_FLAG | V_FLAG; 2.98 - else flags &= ~(C_FLAG | V_FLAG); 2.99 + if ((templ >> 15) != 0 && (templ >> 15) != -1) flags |= C_FLAG | V_FLAG; 2.100 + else flags &= ~(C_FLAG | V_FLAG); 2.101 regs[reg].w = templ & 0xffff; 2.102 2.103 cycles -= (mod == 3) ? 14 : 17; 2.104 @@ -119,7 +119,7 @@ 2.105 2.106 static int opIMUL_l_ib_a16(uint32_t fetchdat) 2.107 { 2.108 - uint64_t temp64; 2.109 + int64_t temp64; 2.110 int32_t templ, templ2; 2.111 2.112 fetch_ea_16(fetchdat); 2.113 @@ -129,8 +129,8 @@ 2.114 2.115 temp64 = ((int64_t)templ)*((int64_t)templ2); 2.116 flags_rebuild(); 2.117 - if ((temp64 >> 32) != 0 && (temp64 >> 32) != 0xffffffff) flags |= C_FLAG | V_FLAG; 2.118 - else flags &= ~(C_FLAG | V_FLAG); 2.119 + if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) flags |= C_FLAG | V_FLAG; 2.120 + else flags &= ~(C_FLAG | V_FLAG); 2.121 regs[reg].l = temp64 & 0xffffffff; 2.122 2.123 cycles -= 20; 2.124 @@ -138,7 +138,7 @@ 2.125 } 2.126 static int opIMUL_l_ib_a32(uint32_t fetchdat) 2.127 { 2.128 - uint64_t temp64; 2.129 + int64_t temp64; 2.130 int32_t templ, templ2; 2.131 2.132 fetch_ea_32(fetchdat); 2.133 @@ -148,8 +148,8 @@ 2.134 2.135 temp64 = ((int64_t)templ)*((int64_t)templ2); 2.136 flags_rebuild(); 2.137 - if ((temp64 >> 32) != 0 && (temp64 >> 32) != 0xffffffff) flags |= C_FLAG | V_FLAG; 2.138 - else flags &= ~(C_FLAG | V_FLAG); 2.139 + if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) flags |= C_FLAG | V_FLAG; 2.140 + else flags &= ~(C_FLAG | V_FLAG); 2.141 regs[reg].l = temp64 & 0xffffffff; 2.142 2.143 cycles -= 20; 2.144 @@ -160,30 +160,30 @@ 2.145 2.146 static int opIMUL_w_w_a16(uint32_t fetchdat) 2.147 { 2.148 - uint32_t templ; 2.149 + int32_t templ; 2.150 2.151 fetch_ea_16(fetchdat); 2.152 templ = (int32_t)(int16_t)regs[reg].w * (int32_t)(int16_t)geteaw(); 2.153 if (abrt) return 0; 2.154 regs[reg].w = templ & 0xFFFF; 2.155 flags_rebuild(); 2.156 - if ((templ >> 16) && (templ >> 16) != 0xFFFF) flags |= C_FLAG | V_FLAG; 2.157 - else flags &= ~(C_FLAG | V_FLAG); 2.158 + if ((templ >> 15) != 0 && (templ >> 15) != -1) flags |= C_FLAG | V_FLAG; 2.159 + else flags &= ~(C_FLAG | V_FLAG); 2.160 2.161 cycles -= 18; 2.162 return 0; 2.163 } 2.164 static int opIMUL_w_w_a32(uint32_t fetchdat) 2.165 { 2.166 - uint32_t templ; 2.167 + int32_t templ; 2.168 2.169 fetch_ea_32(fetchdat); 2.170 templ = (int32_t)(int16_t)regs[reg].w * (int32_t)(int16_t)geteaw(); 2.171 if (abrt) return 0; 2.172 regs[reg].w = templ & 0xFFFF; 2.173 flags_rebuild(); 2.174 - if ((templ >> 16) && (templ >> 16) != 0xFFFF) flags |= C_FLAG | V_FLAG; 2.175 - else flags &= ~(C_FLAG | V_FLAG); 2.176 + if ((templ >> 15) != 0 && (templ >> 15) != -1) flags |= C_FLAG | V_FLAG; 2.177 + else flags &= ~(C_FLAG | V_FLAG); 2.178 2.179 cycles -= 18; 2.180 return 0; 2.181 @@ -191,30 +191,30 @@ 2.182 2.183 static int opIMUL_l_l_a16(uint32_t fetchdat) 2.184 { 2.185 - uint64_t temp64; 2.186 + int64_t temp64; 2.187 2.188 fetch_ea_16(fetchdat); 2.189 temp64 = (int64_t)(int32_t)regs[reg].l * (int64_t)(int32_t)geteal(); 2.190 if (abrt) return 0; 2.191 regs[reg].l = temp64 & 0xFFFFFFFF; 2.192 flags_rebuild(); 2.193 - if ((temp64 >> 32) && (temp64 >> 32) != 0xFFFFFFFF) flags |= C_FLAG | V_FLAG; 2.194 - else flags &= ~(C_FLAG | V_FLAG); 2.195 + if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) flags |= C_FLAG | V_FLAG; 2.196 + else flags &= ~(C_FLAG | V_FLAG); 2.197 2.198 cycles -= 30; 2.199 return 0; 2.200 } 2.201 static int opIMUL_l_l_a32(uint32_t fetchdat) 2.202 { 2.203 - uint64_t temp64; 2.204 + int64_t temp64; 2.205 2.206 fetch_ea_32(fetchdat); 2.207 temp64 = (int64_t)(int32_t)regs[reg].l * (int64_t)(int32_t)geteal(); 2.208 if (abrt) return 0; 2.209 regs[reg].l = temp64 & 0xFFFFFFFF; 2.210 flags_rebuild(); 2.211 - if ((temp64 >> 32) && (temp64 >> 32) != 0xFFFFFFFF) flags |= C_FLAG | V_FLAG; 2.212 - else flags &= ~(C_FLAG | V_FLAG); 2.213 + if ((temp64 >> 31) != 0 && (temp64 >> 31) != -1) flags |= C_FLAG | V_FLAG; 2.214 + else flags &= ~(C_FLAG | V_FLAG); 2.215 2.216 cycles -= 30; 2.217 return 0;
