Changeset 48159 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Aug 29, 2013 2:01:11 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp
r48127 r48159 24 24 25 25 26 /******************************************************************************* 27 * Global Variables * 28 *******************************************************************************/ 29 /** 30 * Parity calculation table. 31 * 32 * The generator code: 33 * @code 34 * #include <stdio.h> 35 * 36 * int main() 37 * { 38 * unsigned b; 39 * for (b = 0; b < 256; b++) 40 * { 41 * int cOnes = ( b & 1) 42 * + ((b >> 1) & 1) 43 * + ((b >> 2) & 1) 44 * + ((b >> 3) & 1) 45 * + ((b >> 4) & 1) 46 * + ((b >> 5) & 1) 47 * + ((b >> 6) & 1) 48 * + ((b >> 7) & 1); 49 * printf(" /" "* %#04x = %u%u%u%u%u%u%u%ub *" "/ %s,\n", 50 * b, 51 * (b >> 7) & 1, 52 * (b >> 6) & 1, 53 * (b >> 5) & 1, 54 * (b >> 4) & 1, 55 * (b >> 3) & 1, 56 * (b >> 2) & 1, 57 * (b >> 1) & 1, 58 * b & 1, 59 * cOnes & 1 ? "0" : "X86_EFL_PF"); 60 * } 61 * return 0; 62 * } 63 * @endcode 64 */ 65 static uint8_t const g_afParity[256] = 66 { 67 /* 0000 = 00000000b */ X86_EFL_PF, 68 /* 0x01 = 00000001b */ 0, 69 /* 0x02 = 00000010b */ 0, 70 /* 0x03 = 00000011b */ X86_EFL_PF, 71 /* 0x04 = 00000100b */ 0, 72 /* 0x05 = 00000101b */ X86_EFL_PF, 73 /* 0x06 = 00000110b */ X86_EFL_PF, 74 /* 0x07 = 00000111b */ 0, 75 /* 0x08 = 00001000b */ 0, 76 /* 0x09 = 00001001b */ X86_EFL_PF, 77 /* 0x0a = 00001010b */ X86_EFL_PF, 78 /* 0x0b = 00001011b */ 0, 79 /* 0x0c = 00001100b */ X86_EFL_PF, 80 /* 0x0d = 00001101b */ 0, 81 /* 0x0e = 00001110b */ 0, 82 /* 0x0f = 00001111b */ X86_EFL_PF, 83 /* 0x10 = 00010000b */ 0, 84 /* 0x11 = 00010001b */ X86_EFL_PF, 85 /* 0x12 = 00010010b */ X86_EFL_PF, 86 /* 0x13 = 00010011b */ 0, 87 /* 0x14 = 00010100b */ X86_EFL_PF, 88 /* 0x15 = 00010101b */ 0, 89 /* 0x16 = 00010110b */ 0, 90 /* 0x17 = 00010111b */ X86_EFL_PF, 91 /* 0x18 = 00011000b */ X86_EFL_PF, 92 /* 0x19 = 00011001b */ 0, 93 /* 0x1a = 00011010b */ 0, 94 /* 0x1b = 00011011b */ X86_EFL_PF, 95 /* 0x1c = 00011100b */ 0, 96 /* 0x1d = 00011101b */ X86_EFL_PF, 97 /* 0x1e = 00011110b */ X86_EFL_PF, 98 /* 0x1f = 00011111b */ 0, 99 /* 0x20 = 00100000b */ 0, 100 /* 0x21 = 00100001b */ X86_EFL_PF, 101 /* 0x22 = 00100010b */ X86_EFL_PF, 102 /* 0x23 = 00100011b */ 0, 103 /* 0x24 = 00100100b */ X86_EFL_PF, 104 /* 0x25 = 00100101b */ 0, 105 /* 0x26 = 00100110b */ 0, 106 /* 0x27 = 00100111b */ X86_EFL_PF, 107 /* 0x28 = 00101000b */ X86_EFL_PF, 108 /* 0x29 = 00101001b */ 0, 109 /* 0x2a = 00101010b */ 0, 110 /* 0x2b = 00101011b */ X86_EFL_PF, 111 /* 0x2c = 00101100b */ 0, 112 /* 0x2d = 00101101b */ X86_EFL_PF, 113 /* 0x2e = 00101110b */ X86_EFL_PF, 114 /* 0x2f = 00101111b */ 0, 115 /* 0x30 = 00110000b */ X86_EFL_PF, 116 /* 0x31 = 00110001b */ 0, 117 /* 0x32 = 00110010b */ 0, 118 /* 0x33 = 00110011b */ X86_EFL_PF, 119 /* 0x34 = 00110100b */ 0, 120 /* 0x35 = 00110101b */ X86_EFL_PF, 121 /* 0x36 = 00110110b */ X86_EFL_PF, 122 /* 0x37 = 00110111b */ 0, 123 /* 0x38 = 00111000b */ 0, 124 /* 0x39 = 00111001b */ X86_EFL_PF, 125 /* 0x3a = 00111010b */ X86_EFL_PF, 126 /* 0x3b = 00111011b */ 0, 127 /* 0x3c = 00111100b */ X86_EFL_PF, 128 /* 0x3d = 00111101b */ 0, 129 /* 0x3e = 00111110b */ 0, 130 /* 0x3f = 00111111b */ X86_EFL_PF, 131 /* 0x40 = 01000000b */ 0, 132 /* 0x41 = 01000001b */ X86_EFL_PF, 133 /* 0x42 = 01000010b */ X86_EFL_PF, 134 /* 0x43 = 01000011b */ 0, 135 /* 0x44 = 01000100b */ X86_EFL_PF, 136 /* 0x45 = 01000101b */ 0, 137 /* 0x46 = 01000110b */ 0, 138 /* 0x47 = 01000111b */ X86_EFL_PF, 139 /* 0x48 = 01001000b */ X86_EFL_PF, 140 /* 0x49 = 01001001b */ 0, 141 /* 0x4a = 01001010b */ 0, 142 /* 0x4b = 01001011b */ X86_EFL_PF, 143 /* 0x4c = 01001100b */ 0, 144 /* 0x4d = 01001101b */ X86_EFL_PF, 145 /* 0x4e = 01001110b */ X86_EFL_PF, 146 /* 0x4f = 01001111b */ 0, 147 /* 0x50 = 01010000b */ X86_EFL_PF, 148 /* 0x51 = 01010001b */ 0, 149 /* 0x52 = 01010010b */ 0, 150 /* 0x53 = 01010011b */ X86_EFL_PF, 151 /* 0x54 = 01010100b */ 0, 152 /* 0x55 = 01010101b */ X86_EFL_PF, 153 /* 0x56 = 01010110b */ X86_EFL_PF, 154 /* 0x57 = 01010111b */ 0, 155 /* 0x58 = 01011000b */ 0, 156 /* 0x59 = 01011001b */ X86_EFL_PF, 157 /* 0x5a = 01011010b */ X86_EFL_PF, 158 /* 0x5b = 01011011b */ 0, 159 /* 0x5c = 01011100b */ X86_EFL_PF, 160 /* 0x5d = 01011101b */ 0, 161 /* 0x5e = 01011110b */ 0, 162 /* 0x5f = 01011111b */ X86_EFL_PF, 163 /* 0x60 = 01100000b */ X86_EFL_PF, 164 /* 0x61 = 01100001b */ 0, 165 /* 0x62 = 01100010b */ 0, 166 /* 0x63 = 01100011b */ X86_EFL_PF, 167 /* 0x64 = 01100100b */ 0, 168 /* 0x65 = 01100101b */ X86_EFL_PF, 169 /* 0x66 = 01100110b */ X86_EFL_PF, 170 /* 0x67 = 01100111b */ 0, 171 /* 0x68 = 01101000b */ 0, 172 /* 0x69 = 01101001b */ X86_EFL_PF, 173 /* 0x6a = 01101010b */ X86_EFL_PF, 174 /* 0x6b = 01101011b */ 0, 175 /* 0x6c = 01101100b */ X86_EFL_PF, 176 /* 0x6d = 01101101b */ 0, 177 /* 0x6e = 01101110b */ 0, 178 /* 0x6f = 01101111b */ X86_EFL_PF, 179 /* 0x70 = 01110000b */ 0, 180 /* 0x71 = 01110001b */ X86_EFL_PF, 181 /* 0x72 = 01110010b */ X86_EFL_PF, 182 /* 0x73 = 01110011b */ 0, 183 /* 0x74 = 01110100b */ X86_EFL_PF, 184 /* 0x75 = 01110101b */ 0, 185 /* 0x76 = 01110110b */ 0, 186 /* 0x77 = 01110111b */ X86_EFL_PF, 187 /* 0x78 = 01111000b */ X86_EFL_PF, 188 /* 0x79 = 01111001b */ 0, 189 /* 0x7a = 01111010b */ 0, 190 /* 0x7b = 01111011b */ X86_EFL_PF, 191 /* 0x7c = 01111100b */ 0, 192 /* 0x7d = 01111101b */ X86_EFL_PF, 193 /* 0x7e = 01111110b */ X86_EFL_PF, 194 /* 0x7f = 01111111b */ 0, 195 /* 0x80 = 10000000b */ 0, 196 /* 0x81 = 10000001b */ X86_EFL_PF, 197 /* 0x82 = 10000010b */ X86_EFL_PF, 198 /* 0x83 = 10000011b */ 0, 199 /* 0x84 = 10000100b */ X86_EFL_PF, 200 /* 0x85 = 10000101b */ 0, 201 /* 0x86 = 10000110b */ 0, 202 /* 0x87 = 10000111b */ X86_EFL_PF, 203 /* 0x88 = 10001000b */ X86_EFL_PF, 204 /* 0x89 = 10001001b */ 0, 205 /* 0x8a = 10001010b */ 0, 206 /* 0x8b = 10001011b */ X86_EFL_PF, 207 /* 0x8c = 10001100b */ 0, 208 /* 0x8d = 10001101b */ X86_EFL_PF, 209 /* 0x8e = 10001110b */ X86_EFL_PF, 210 /* 0x8f = 10001111b */ 0, 211 /* 0x90 = 10010000b */ X86_EFL_PF, 212 /* 0x91 = 10010001b */ 0, 213 /* 0x92 = 10010010b */ 0, 214 /* 0x93 = 10010011b */ X86_EFL_PF, 215 /* 0x94 = 10010100b */ 0, 216 /* 0x95 = 10010101b */ X86_EFL_PF, 217 /* 0x96 = 10010110b */ X86_EFL_PF, 218 /* 0x97 = 10010111b */ 0, 219 /* 0x98 = 10011000b */ 0, 220 /* 0x99 = 10011001b */ X86_EFL_PF, 221 /* 0x9a = 10011010b */ X86_EFL_PF, 222 /* 0x9b = 10011011b */ 0, 223 /* 0x9c = 10011100b */ X86_EFL_PF, 224 /* 0x9d = 10011101b */ 0, 225 /* 0x9e = 10011110b */ 0, 226 /* 0x9f = 10011111b */ X86_EFL_PF, 227 /* 0xa0 = 10100000b */ X86_EFL_PF, 228 /* 0xa1 = 10100001b */ 0, 229 /* 0xa2 = 10100010b */ 0, 230 /* 0xa3 = 10100011b */ X86_EFL_PF, 231 /* 0xa4 = 10100100b */ 0, 232 /* 0xa5 = 10100101b */ X86_EFL_PF, 233 /* 0xa6 = 10100110b */ X86_EFL_PF, 234 /* 0xa7 = 10100111b */ 0, 235 /* 0xa8 = 10101000b */ 0, 236 /* 0xa9 = 10101001b */ X86_EFL_PF, 237 /* 0xaa = 10101010b */ X86_EFL_PF, 238 /* 0xab = 10101011b */ 0, 239 /* 0xac = 10101100b */ X86_EFL_PF, 240 /* 0xad = 10101101b */ 0, 241 /* 0xae = 10101110b */ 0, 242 /* 0xaf = 10101111b */ X86_EFL_PF, 243 /* 0xb0 = 10110000b */ 0, 244 /* 0xb1 = 10110001b */ X86_EFL_PF, 245 /* 0xb2 = 10110010b */ X86_EFL_PF, 246 /* 0xb3 = 10110011b */ 0, 247 /* 0xb4 = 10110100b */ X86_EFL_PF, 248 /* 0xb5 = 10110101b */ 0, 249 /* 0xb6 = 10110110b */ 0, 250 /* 0xb7 = 10110111b */ X86_EFL_PF, 251 /* 0xb8 = 10111000b */ X86_EFL_PF, 252 /* 0xb9 = 10111001b */ 0, 253 /* 0xba = 10111010b */ 0, 254 /* 0xbb = 10111011b */ X86_EFL_PF, 255 /* 0xbc = 10111100b */ 0, 256 /* 0xbd = 10111101b */ X86_EFL_PF, 257 /* 0xbe = 10111110b */ X86_EFL_PF, 258 /* 0xbf = 10111111b */ 0, 259 /* 0xc0 = 11000000b */ X86_EFL_PF, 260 /* 0xc1 = 11000001b */ 0, 261 /* 0xc2 = 11000010b */ 0, 262 /* 0xc3 = 11000011b */ X86_EFL_PF, 263 /* 0xc4 = 11000100b */ 0, 264 /* 0xc5 = 11000101b */ X86_EFL_PF, 265 /* 0xc6 = 11000110b */ X86_EFL_PF, 266 /* 0xc7 = 11000111b */ 0, 267 /* 0xc8 = 11001000b */ 0, 268 /* 0xc9 = 11001001b */ X86_EFL_PF, 269 /* 0xca = 11001010b */ X86_EFL_PF, 270 /* 0xcb = 11001011b */ 0, 271 /* 0xcc = 11001100b */ X86_EFL_PF, 272 /* 0xcd = 11001101b */ 0, 273 /* 0xce = 11001110b */ 0, 274 /* 0xcf = 11001111b */ X86_EFL_PF, 275 /* 0xd0 = 11010000b */ 0, 276 /* 0xd1 = 11010001b */ X86_EFL_PF, 277 /* 0xd2 = 11010010b */ X86_EFL_PF, 278 /* 0xd3 = 11010011b */ 0, 279 /* 0xd4 = 11010100b */ X86_EFL_PF, 280 /* 0xd5 = 11010101b */ 0, 281 /* 0xd6 = 11010110b */ 0, 282 /* 0xd7 = 11010111b */ X86_EFL_PF, 283 /* 0xd8 = 11011000b */ X86_EFL_PF, 284 /* 0xd9 = 11011001b */ 0, 285 /* 0xda = 11011010b */ 0, 286 /* 0xdb = 11011011b */ X86_EFL_PF, 287 /* 0xdc = 11011100b */ 0, 288 /* 0xdd = 11011101b */ X86_EFL_PF, 289 /* 0xde = 11011110b */ X86_EFL_PF, 290 /* 0xdf = 11011111b */ 0, 291 /* 0xe0 = 11100000b */ 0, 292 /* 0xe1 = 11100001b */ X86_EFL_PF, 293 /* 0xe2 = 11100010b */ X86_EFL_PF, 294 /* 0xe3 = 11100011b */ 0, 295 /* 0xe4 = 11100100b */ X86_EFL_PF, 296 /* 0xe5 = 11100101b */ 0, 297 /* 0xe6 = 11100110b */ 0, 298 /* 0xe7 = 11100111b */ X86_EFL_PF, 299 /* 0xe8 = 11101000b */ X86_EFL_PF, 300 /* 0xe9 = 11101001b */ 0, 301 /* 0xea = 11101010b */ 0, 302 /* 0xeb = 11101011b */ X86_EFL_PF, 303 /* 0xec = 11101100b */ 0, 304 /* 0xed = 11101101b */ X86_EFL_PF, 305 /* 0xee = 11101110b */ X86_EFL_PF, 306 /* 0xef = 11101111b */ 0, 307 /* 0xf0 = 11110000b */ X86_EFL_PF, 308 /* 0xf1 = 11110001b */ 0, 309 /* 0xf2 = 11110010b */ 0, 310 /* 0xf3 = 11110011b */ X86_EFL_PF, 311 /* 0xf4 = 11110100b */ 0, 312 /* 0xf5 = 11110101b */ X86_EFL_PF, 313 /* 0xf6 = 11110110b */ X86_EFL_PF, 314 /* 0xf7 = 11110111b */ 0, 315 /* 0xf8 = 11111000b */ 0, 316 /* 0xf9 = 11111001b */ X86_EFL_PF, 317 /* 0xfa = 11111010b */ X86_EFL_PF, 318 /* 0xfb = 11111011b */ 0, 319 /* 0xfc = 11111100b */ X86_EFL_PF, 320 /* 0xfd = 11111101b */ 0, 321 /* 0xfe = 11111110b */ 0, 322 /* 0xff = 11111111b */ X86_EFL_PF, 323 }; 324 325 326 /** 327 * Calculates the signed flag value given a result and it's bit width. 328 * 329 * The signed flag (SF) is a duplication of the most significant bit in the 330 * result. 331 * 332 * @returns X86_EFL_SF or 0. 333 * @param a_uResult Unsigned result value. 334 * @param a_cBitsWidth The width of the result (8, 16, 32, 64). 335 */ 336 #define X86_EFL_CALC_SF(a_uResult, a_cBitsWidth) \ 337 ( (uint32_t)((a_uResult) >> ((a_cBitsWidth) - X86_EFL_SF_BIT)) & X86_EFL_SF ) 338 339 /** 340 * Calculates the zero flag value given a result. 341 * 342 * The zero flag (ZF) indicates whether the result is zero or not. 343 * 344 * @returns X86_EFL_ZF or 0. 345 * @param a_uResult Unsigned result value. 346 */ 347 #define X86_EFL_CALC_ZF(a_uResult) \ 348 ( (uint32_t)((a_uResult) == 0) << X86_EFL_ZF_BIT ) 349 350 /** 351 * Updates the status bits (CF, PF, AF, ZF, SF, and OF) after a logical op. 352 * 353 * CF and OF are defined to be 0 by logical operations. AF on the other hand is 354 * undefined. We do not set AF, as that seems to make the most sense (which 355 * probably makes it the most wrong in real life). 356 * 357 * @returns Status bits. 358 * @param a_pfEFlags Pointer to the 32-bit EFLAGS value to update. 359 * @param a_uResult Unsigned result value. 360 * @param a_cBitsWidth The width of the result (8, 16, 32, 64). 361 * @param a_fExtra Additional bits to set. 362 */ 363 #define IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(a_pfEFlags, a_uResult, a_cBitsWidth, a_fExtra) \ 364 do { \ 365 uint32_t fEflTmp = *(a_pfEFlags); \ 366 fEflTmp &= ~X86_EFL_STATUS_BITS; \ 367 fEflTmp |= g_afParity[(a_uResult) & 0xff]; \ 368 fEflTmp |= X86_EFL_CALC_ZF(a_uResult); \ 369 fEflTmp |= X86_EFL_CALC_SF(a_uResult, a_cBitsWidth); \ 370 fEflTmp |= (a_fExtra); \ 371 *(a_pfEFlags) = fEflTmp; \ 372 } while (0) 373 374 26 375 #ifdef RT_ARCH_X86 27 376 /* … … 35 384 IEM_DECL_IMPL_DEF(void, iemAImpl_add_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 36 385 { 37 AssertFailed(); 386 uint64_t uDst = *puDst; 387 uint64_t uResult = uDst + uSrc; 388 *puDst = uResult; 389 390 /* Calc EFLAGS. */ 391 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; 392 fEfl |= (uResult < uDst) << X86_EFL_CF_BIT; 393 fEfl |= g_afParity[uResult & 0xff]; 394 fEfl |= ((uint32_t)uResult ^ (uint32_t)uSrc ^ (uint32_t)uDst) & X86_EFL_AF; 395 fEfl |= X86_EFL_CALC_ZF(uResult); 396 fEfl |= X86_EFL_CALC_SF(uResult, 64); 397 fEfl |= (((uDst ^ uSrc ^ RT_BIT_64(63)) & (uResult ^ uDst)) >> (64 - X86_EFL_OF_BIT)) & X86_EFL_OF; 398 *pfEFlags = fEfl; 38 399 } 39 400 … … 41 402 IEM_DECL_IMPL_DEF(void, iemAImpl_adc_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 42 403 { 43 AssertFailed(); 404 if (!(*pfEFlags & X86_EFL_CF)) 405 iemAImpl_add_u64(puDst, uSrc, pfEFlags); 406 else 407 { 408 uint64_t uDst = *puDst; 409 uint64_t uResult = uDst + uSrc + 1; 410 *puDst = uResult; 411 412 /* Calc EFLAGS. */ 413 /** @todo verify AF and OF calculations. */ 414 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; 415 fEfl |= (uResult <= uDst) << X86_EFL_CF_BIT; 416 fEfl |= g_afParity[uResult & 0xff]; 417 fEfl |= ((uint32_t)uResult ^ (uint32_t)uSrc ^ (uint32_t)uDst) & X86_EFL_AF; 418 fEfl |= X86_EFL_CALC_ZF(uResult); 419 fEfl |= X86_EFL_CALC_SF(uResult, 64); 420 fEfl |= (((uDst ^ uSrc ^ RT_BIT_64(63)) & (uResult ^ uDst)) >> (64 - X86_EFL_OF_BIT)) & X86_EFL_OF; 421 *pfEFlags = fEfl; 422 } 44 423 } 45 424 … … 47 426 IEM_DECL_IMPL_DEF(void, iemAImpl_sub_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 48 427 { 49 AssertFailed(); 428 uint64_t uDst = *puDst; 429 uint64_t uResult = uDst - uSrc; 430 *puDst = uResult; 431 432 /* Calc EFLAGS. */ 433 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; 434 fEfl |= (uDst < uSrc) << X86_EFL_CF_BIT; 435 fEfl |= g_afParity[uResult & 0xff]; 436 fEfl |= ((uint32_t)uResult ^ (uint32_t)uSrc ^ (uint32_t)uDst) & X86_EFL_AF; 437 fEfl |= X86_EFL_CALC_ZF(uResult); 438 fEfl |= X86_EFL_CALC_SF(uResult, 64); 439 fEfl |= (((uDst ^ uSrc) & (uResult ^ uDst)) >> (64 - X86_EFL_OF_BIT)) & X86_EFL_OF; 440 *pfEFlags = fEfl; 50 441 } 51 442 … … 53 444 IEM_DECL_IMPL_DEF(void, iemAImpl_sbb_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 54 445 { 55 AssertFailed(); 446 if (!(*pfEFlags & X86_EFL_CF)) 447 iemAImpl_sub_u64(puDst, uSrc, pfEFlags); 448 else 449 { 450 uint64_t uDst = *puDst; 451 uint64_t uResult = uDst - uSrc - 1; 452 *puDst = uResult; 453 454 /* Calc EFLAGS. */ 455 /** @todo verify AF and OF calculations. */ 456 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; 457 fEfl |= (uDst <= uSrc) << X86_EFL_CF_BIT; 458 fEfl |= g_afParity[uResult & 0xff]; 459 fEfl |= ((uint32_t)uResult ^ (uint32_t)uSrc ^ (uint32_t)uDst) & X86_EFL_AF; 460 fEfl |= X86_EFL_CALC_ZF(uResult); 461 fEfl |= X86_EFL_CALC_SF(uResult, 64); 462 fEfl |= (((uDst ^ uSrc) & (uResult ^ uDst)) >> (64 - X86_EFL_OF_BIT)) & X86_EFL_OF; 463 *pfEFlags = fEfl; 464 } 56 465 } 57 466 … … 59 468 IEM_DECL_IMPL_DEF(void, iemAImpl_or_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 60 469 { 61 AssertFailed(); 470 uint64_t uResult = *puDst | uSrc; 471 *puDst = uResult; 472 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 64, 0); 62 473 } 63 474 … … 65 476 IEM_DECL_IMPL_DEF(void, iemAImpl_xor_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 66 477 { 67 AssertFailed(); 478 uint64_t uResult = *puDst ^ uSrc; 479 *puDst = uResult; 480 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 64, 0); 68 481 } 69 482 … … 71 484 IEM_DECL_IMPL_DEF(void, iemAImpl_and_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 72 485 { 73 AssertFailed(); 486 uint64_t uResult = *puDst & uSrc; 487 *puDst = uResult; 488 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 64, 0); 74 489 } 75 490 … … 77 492 IEM_DECL_IMPL_DEF(void, iemAImpl_cmp_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 78 493 { 79 AssertFailed(); 494 uint64_t uDstTmp = *puDst; 495 iemAImpl_sub_u64(&uDstTmp, uSrc, pfEFlags); 80 496 } 81 497 … … 83 499 IEM_DECL_IMPL_DEF(void, iemAImpl_test_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 84 500 { 85 AssertFailed(); 501 uint64_t uResult = *puDst & uSrc; 502 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 64, 0); 86 503 } 87 504 … … 149 566 IEM_DECL_IMPL_DEF(void, iemAImpl_bt_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 150 567 { 151 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. */ 568 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an 569 logical operation (AND/OR/whatever). */ 152 570 Assert(uSrc < 64); 153 if (*puDst & RT_BIT_64(uSrc)) 154 *pfEFlags |= X86_EFL_CF; 571 uint64_t uDst = *puDst; 572 if (uDst & RT_BIT_64(uSrc)) 573 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uDst, 64, X86_EFL_CF); 155 574 else 156 *pfEFlags &= ~X86_EFL_CF;575 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uDst, 64, 0); 157 576 } 158 577 159 578 IEM_DECL_IMPL_DEF(void, iemAImpl_btc_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 160 579 { 161 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. */ 580 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an 581 logical operation (AND/OR/whatever). */ 162 582 Assert(uSrc < 64); 163 583 uint64_t fMask = RT_BIT_64(uSrc); 164 if (*puDst & fMask) 584 uint64_t uDst = *puDst; 585 if (uDst & fMask) 165 586 { 166 *puDst &= ~fMask; 167 *pfEFlags |= X86_EFL_CF; 587 uDst &= ~fMask; 588 *puDst = uDst; 589 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uDst, 64, X86_EFL_CF); 168 590 } 169 591 else 170 592 { 171 *puDst |= ~fMask; 172 *pfEFlags &= ~X86_EFL_CF; 593 uDst |= fMask; 594 *puDst = uDst; 595 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uDst, 64, 0); 173 596 } 174 597 } … … 176 599 IEM_DECL_IMPL_DEF(void, iemAImpl_btr_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 177 600 { 178 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. */ 601 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an 602 logical operation (AND/OR/whatever). */ 603 Assert(uSrc < 64); 179 604 uint64_t fMask = RT_BIT_64(uSrc); 180 if (*puDst & fMask) 181 *pfEFlags |= X86_EFL_CF; 605 uint64_t uDst = *puDst; 606 if (uDst & fMask) 607 { 608 uDst &= ~fMask; 609 *puDst = uDst; 610 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uDst, 64, X86_EFL_CF); 611 } 182 612 else 183 *pfEFlags &= ~X86_EFL_CF; 184 *puDst &= ~fMask; 613 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uDst, 64, 0); 185 614 } 186 615 187 616 IEM_DECL_IMPL_DEF(void, iemAImpl_bts_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags)) 188 617 { 189 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. */ 618 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an 619 logical operation (AND/OR/whatever). */ 620 Assert(uSrc < 64); 190 621 uint64_t fMask = RT_BIT_64(uSrc); 191 if (*puDst & fMask) 192 *pfEFlags |= X86_EFL_CF; 622 uint64_t uDst = *puDst; 623 if (uDst & fMask) 624 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uDst, 64, X86_EFL_CF); 193 625 else 194 *pfEFlags &= ~X86_EFL_CF; 195 *puDst |= fMask; 626 { 627 uDst |= fMask; 628 *puDst = uDst; 629 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uDst, 64, 0); 630 } 196 631 } 197 632 … … 218 653 { 219 654 /* Note! "undefined" flags: OF, SF, AF, PF, CF. */ 655 /** @todo check what real CPUs does. */ 220 656 if (uSrc) 221 657 { … … 268 704 { 269 705 /* Note! "undefined" flags: OF, SF, AF, PF, CF. */ 706 /** @todo check what real CPUs does. */ 270 707 if (uSrc) 271 708 {
Note:
See TracChangeset
for help on using the changeset viewer.