Changeset 58701 in vbox for trunk/include/iprt/asm-amd64-x86-watcom-32.h
- Timestamp:
- Nov 16, 2015 4:21:44 PM (9 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm-amd64-x86-watcom-32.h
r58699 r58701 1 1 /** @file 2 * IPRT - AMD64 and x86 Specific Assembly Functions, 16-bit Watcom C pragma aux.2 * IPRT - AMD64 and x86 Specific Assembly Functions, 32-bit Watcom C pragma aux. 3 3 */ 4 4 … … 27 27 # error "Don't include this header directly." 28 28 #endif 29 #ifndef ___iprt_asm_amd64_x86_watcom_ 16_h30 #define ___iprt_asm_amd64_x86_watcom_ 16_h31 32 #if !RT_FAR_DATA33 # error "Only works with f ar data pointers!"29 #ifndef ___iprt_asm_amd64_x86_watcom_32_h 30 #define ___iprt_asm_amd64_x86_watcom_32_h 31 32 #ifndef __FLAT__ 33 # error "Only works with flat pointers! (-mf)" 34 34 #endif 35 35 36 /*37 * Turns out we cannot use 'ds' for segment stuff here because the compiler38 * seems to insists on loading the DGROUP segment into 'ds' before calling39 * stuff when using -ecc. Using 'es' instead as this seems to work fine.40 */41 36 42 37 #pragma aux ASMGetIDTR = \ 43 "sidt fword ptr es:[bx]" \44 parm [e s bx] \38 "sidt fword ptr [ecx]" \ 39 parm [ecx] \ 45 40 modify exact []; 46 41 47 42 #pragma aux ASMGetIdtrLimit = \ 48 "sub sp, 8" \ 49 "mov bx, sp" \ 50 "sidt fword ptr ss:[bx]" \ 51 "mov bx, ss:[bx]" \ 52 "add sp, 8" \ 43 "sub esp, 8" \ 44 "sidt fword ptr [esp]" \ 45 "mov cx, [esp]" \ 46 "add esp, 8" \ 53 47 parm [] \ 54 value [ bx] \55 modify exact [ bx];48 value [cx] \ 49 modify exact [ecx]; 56 50 57 51 #pragma aux ASMSetIDTR = \ 58 "lidt fword ptr es:[bx]" \59 parm [e s bx] nomemory \52 "lidt fword ptr [ecx]" \ 53 parm [ecx] nomemory \ 60 54 modify nomemory; 61 55 62 56 #pragma aux ASMGetGDTR = \ 63 "sgdt fword ptr es:[bx]" \64 parm [e s bx] \57 "sgdt fword ptr [ecx]" \ 58 parm [ecx] \ 65 59 modify exact []; 66 60 67 61 #pragma aux ASMSetGDTR = \ 68 "lgdt fword ptr es:[bx]" \69 parm [e s bx] nomemory \62 "lgdt fword ptr [ecx]" \ 63 parm [ecx] nomemory \ 70 64 modify exact [] nomemory; 71 65 … … 74 68 parm [] nomemory \ 75 69 value [ax] \ 76 modify exact [ ax] nomemory;70 modify exact [eax] nomemory; 77 71 78 72 #pragma aux ASMGetDS = \ … … 80 74 parm [] nomemory \ 81 75 value [ax] \ 82 modify exact [ ax] nomemory;76 modify exact [eax] nomemory; 83 77 84 78 #pragma aux ASMGetES = \ … … 86 80 parm [] nomemory \ 87 81 value [ax] \ 88 modify exact [ ax] nomemory;82 modify exact [eax] nomemory; 89 83 90 84 #pragma aux ASMGetFS = \ … … 92 86 parm [] nomemory \ 93 87 value [ax] \ 94 modify exact [ ax] nomemory;88 modify exact [eax] nomemory; 95 89 96 90 #pragma aux ASMGetGS = \ … … 98 92 parm [] nomemory \ 99 93 value [ax] \ 100 modify exact [ ax] nomemory;94 modify exact [eax] nomemory; 101 95 102 96 #pragma aux ASMGetSS = \ … … 104 98 parm [] nomemory \ 105 99 value [ax] \ 106 modify exact [ ax] nomemory;100 modify exact [eax] nomemory; 107 101 108 102 #pragma aux ASMGetTR = \ … … 110 104 parm [] nomemory \ 111 105 value [ax] \ 112 modify exact [ ax] nomemory;106 modify exact [eax] nomemory; 113 107 114 108 #pragma aux ASMGetLDTR = \ … … 116 110 parm [] nomemory \ 117 111 value [ax] \ 118 modify exact [ax] nomemory; 119 120 #pragma aux ASMGetGS = \ 121 "mov ax, gs" \ 122 parm [] nomemory \ 123 value [ax] \ 124 modify exact [ax] nomemory; 112 modify exact [eax] nomemory; 125 113 126 114 /** @todo ASMGetSegAttr */ 127 115 128 116 #pragma aux ASMGetFlags = \ 129 "pushf " \130 "pop ax" \131 parm [] nomemory \ 132 value [ ax] \133 modify exact [ ax] nomemory;117 "pushfd" \ 118 "pop eax" \ 119 parm [] nomemory \ 120 value [eax] \ 121 modify exact [eax] nomemory; 134 122 135 123 #pragma aux ASMSetFlags = \ 136 "push ax" \137 "popf " \138 parm [ ax] nomemory \124 "push eax" \ 125 "popfd" \ 126 parm [eax] nomemory \ 139 127 modify exact [] nomemory; 140 128 141 129 #pragma aux ASMChangeFlags = \ 142 "pushf " \143 "pop ax" \144 "and dx,ax" \145 "or dx,cx" \146 "push dx" \147 "popf " \148 parm [ dx] [cx] nomemory \149 value [ ax] \150 modify exact [ dx] nomemory;130 "pushfd" \ 131 "pop eax" \ 132 "and edx, eax" \ 133 "or edx, ecx" \ 134 "push edx" \ 135 "popfd" \ 136 parm [edx] [ecx] nomemory \ 137 value [eax] \ 138 modify exact [edx] nomemory; 151 139 152 140 #pragma aux ASMAddFlags = \ 153 "pushf " \154 "pop ax" \155 "or dx,ax" \156 "push dx" \157 "popf " \158 parm [ dx] nomemory \159 value [ ax] \160 modify exact [ dx] nomemory;141 "pushfd" \ 142 "pop eax" \ 143 "or edx, eax" \ 144 "push edx" \ 145 "popfd" \ 146 parm [edx] nomemory \ 147 value [eax] \ 148 modify exact [edx] nomemory; 161 149 162 150 #pragma aux ASMClearFlags = \ 163 "pushf " \164 "pop ax" \165 "and dx,ax" \166 "push dx" \167 "popf " \168 parm [ dx] nomemory \169 value [ ax] \170 modify exact [ dx] nomemory;151 "pushfd" \ 152 "pop eax" \ 153 "and edx, eax" \ 154 "push edx" \ 155 "popfd" \ 156 parm [edx] nomemory \ 157 value [eax] \ 158 modify exact [edx] nomemory; 171 159 172 160 /* Note! Must use the 64-bit integer return value convension. … … 175 163 ".586" \ 176 164 "rdtsc" \ 177 "mov ebx, edx" \ 178 "mov ecx, eax" \ 179 "shr ecx, 16" \ 180 "xchg eax, edx" \ 181 "shr eax, 16" \ 182 parm [] nomemory \ 183 value [dx cx bx ax] \ 184 modify exact [ax bx cx dx] nomemory; 185 186 /** @todo ASMReadTscWithAux if needed (rdtscp not recognized by compiler) */ 187 165 parm [] nomemory \ 166 value [eax edx] \ 167 modify exact [edx eax] nomemory; 168 169 #pragma aux ASMReadTscWithAux = \ 170 0x0f 0x01 0xf9 \ 171 parm [ecx] \ 172 value [eax edx] \ 173 modify exact [eax edx]; 188 174 189 175 /* ASMCpuId: Implemented externally, too many parameters. */ 190 176 /* ASMCpuId_Idx_ECX: Implemented externally, too many parameters. */ 191 177 /* ASMCpuIdExSlow: Always implemented externally. */ 192 /* ASMCpuId_ECX_EDX: Implemented externally, too many parameters. */ 193 /* ASMCpuId_EAX: Implemented externally, lazy bird. */ 194 /* ASMCpuId_EBX: Implemented externally, lazy bird. */ 195 /* ASMCpuId_ECX: Implemented externally, lazy bird. */ 196 /* ASMCpuId_EDX: Implemented externally, lazy bird. */ 178 179 #pragma aux ASMCpuId_ECX_EDX = \ 180 "cpuid" \ 181 "mov [edi], ecx" \ 182 "mov [esi], edx" \ 183 parm [ecx] [edi] [esi] \ 184 modify exact [eax ebx ecx edx]; 185 186 #pragma aux ASMCpuId_EAX = \ 187 "cpuid" \ 188 parm [ecx] \ 189 value [eax] \ 190 modify exact [eax ebx ecx edx]; 191 192 #pragma aux ASMCpuId_EBX = \ 193 "cpuid" \ 194 parm [ecx] \ 195 value [ebx] \ 196 modify exact [eax ebx ecx edx]; 197 198 #pragma aux ASMCpuId_ECX = \ 199 "cpuid" \ 200 parm [ecx] \ 201 value [ecx] \ 202 modify exact [eax ebx ecx edx]; 203 204 #pragma aux ASMCpuId_EDX = \ 205 "cpuid" \ 206 parm [ecx] \ 207 value [edx] \ 208 modify exact [eax ebx ecx edx]; 209 197 210 /* ASMHasCpuId: MSC inline in main source file. */ 198 211 /* ASMGetApicId: Implemented externally, lazy bird. */ 199 212 200 /* Note! Again, when returning two registers, watcom have certain fixed ordering rules (low:high):201 ax:bx, ax:cx, ax:dx, ax:si, ax:di202 bx:cx, bx:dx, bx:si, bx:di203 dx:cx, si:cx, di:cx204 si:dx, di:dx205 si:di206 This ordering seems to apply to parameter values too. */207 213 #pragma aux ASMGetCR0 = \ 208 214 "mov eax, cr0" \ 209 "mov edx, eax" \ 210 "shr edx, 16" \ 211 parm [] nomemory \ 212 value [ax dx] \ 213 modify exact [ax dx] nomemory; 215 parm [] nomemory \ 216 value [eax] \ 217 modify exact [eax] nomemory; 214 218 215 219 #pragma aux ASMSetCR0 = \ 216 "shl edx, 16" \ 217 "mov dx, ax" \ 218 "mov cr0, edx" \ 219 parm [ax dx] nomemory \ 220 modify exact [dx] nomemory; 220 "mov cr0, eax" \ 221 parm [eax] nomemory \ 222 modify exact [] nomemory; 221 223 222 224 #pragma aux ASMGetCR2 = \ 223 225 "mov eax, cr2" \ 224 "mov edx, eax" \ 225 "shr edx, 16" \ 226 parm [] nomemory \ 227 value [ax dx] \ 228 modify exact [ax dx] nomemory; 226 parm [] nomemory \ 227 value [eax] \ 228 modify exact [eax] nomemory; 229 229 230 230 #pragma aux ASMSetCR2 = \ 231 "shl edx, 16" \ 232 "mov dx, ax" \ 233 "mov cr2, edx" \ 234 parm [ax dx] nomemory \ 235 modify exact [dx] nomemory; 231 "mov cr2, eax" \ 232 parm [eax] nomemory \ 233 modify exact [] nomemory; 236 234 237 235 #pragma aux ASMGetCR3 = \ 238 236 "mov eax, cr3" \ 239 "mov edx, eax" \ 240 "shr edx, 16" \ 241 parm [] nomemory \ 242 value [ax dx] \ 243 modify exact [ax dx] nomemory; 237 parm [] nomemory \ 238 value [eax] \ 239 modify exact [eax] nomemory; 244 240 245 241 #pragma aux ASMSetCR3 = \ 246 "shl edx, 16" \ 247 "mov dx, ax" \ 248 "mov cr3, edx" \ 249 parm [ax dx] nomemory \ 250 modify exact [dx] nomemory; 242 "mov cr3, eax" \ 243 parm [eax] nomemory \ 244 modify exact [] nomemory; 251 245 252 246 #pragma aux ASMReloadCR3 = \ … … 254 248 "mov cr3, eax" \ 255 249 parm [] nomemory \ 256 modify exact [ ax] nomemory;250 modify exact [eax] nomemory; 257 251 258 252 #pragma aux ASMGetCR4 = \ 259 253 "mov eax, cr4" \ 260 "mov edx, eax" \ 261 "shr edx, 16" \ 262 parm [] nomemory \ 263 value [ax dx] \ 264 modify exact [ax dx] nomemory; 254 parm [] nomemory \ 255 value [eax] \ 256 modify exact [eax] nomemory; 265 257 266 258 #pragma aux ASMSetCR4 = \ 267 "shl edx, 16" \ 268 "mov dx, ax" \ 269 "mov cr4, edx" \ 270 parm [ax dx] nomemory \ 271 modify exact [dx] nomemory; 272 273 /* ASMGetCR8: Don't bother for 16-bit. */ 274 /* ASMSetCR8: Don't bother for 16-bit. */ 259 "mov cr4, eax" \ 260 parm [eax] nomemory \ 261 modify exact [] nomemory; 262 263 /* ASMGetCR8: Don't bother for 32-bit. */ 264 /* ASMSetCR8: Don't bother for 32-bit. */ 275 265 276 266 #pragma aux ASMIntEnable = \ … … 285 275 286 276 #pragma aux ASMIntDisableFlags = \ 287 "pushf " \277 "pushfd" \ 288 278 "cli" \ 289 "pop ax" \290 parm [] nomemory \ 291 value [ ax] \279 "pop eax" \ 280 parm [] nomemory \ 281 value [eax] \ 292 282 modify exact [] nomemory; 293 283 … … 299 289 #pragma aux ASMRdMsr = \ 300 290 ".586" \ 301 "shl ecx, 16" \302 "mov cx, ax" \303 291 "rdmsr" \ 304 "mov ebx, edx" \ 305 "mov ecx, eax" \ 306 "shr ecx, 16" \ 307 "xchg eax, edx" \ 308 "shr eax, 16" \ 309 parm [ax cx] nomemory \ 310 value [dx cx bx ax] \ 311 modify exact [ax bx cx dx] nomemory; 312 313 /* ASMWrMsr: Implemented externally, lazy bird. */ 314 /* ASMRdMsrEx: Implemented externally, lazy bird. */ 315 /* ASMWrMsrEx: Implemented externally, lazy bird. */ 292 parm [ecx] nomemory \ 293 value [eax edx] \ 294 modify exact [eax edx] nomemory; 295 296 #pragma aux ASMWrMsr = \ 297 ".586" \ 298 "wrmsr" \ 299 parm [ecx] [eax edx] nomemory \ 300 modify exact [] nomemory; 301 302 #pragma aux ASMRdMsrEx = \ 303 ".586" \ 304 "rdmsr" \ 305 parm [ecx] [edi] nomemory \ 306 value [eax edx] \ 307 modify exact [eax edx] nomemory; 308 309 #pragma aux ASMWrMsrEx = \ 310 ".586" \ 311 "wrmsr" \ 312 parm [ecx] [edi] [eax edx] nomemory \ 313 modify exact [] nomemory; 316 314 317 315 #pragma aux ASMRdMsr_Low = \ 318 316 ".586" \ 319 "shl ecx, 16" \320 "mov cx, ax" \321 317 "rdmsr" \ 322 "mov edx, eax" \ 323 "shr edx, 16" \ 324 parm [ax cx] nomemory \ 325 value [ax dx] \ 326 modify exact [ax bx cx dx] nomemory; 318 parm [ecx] nomemory \ 319 value [eax] \ 320 modify exact [eax edx] nomemory; 327 321 328 322 #pragma aux ASMRdMsr_High = \ 329 323 ".586" \ 330 "shl ecx, 16" \331 "mov cx, ax" \332 324 "rdmsr" \ 333 "mov eax, edx" \ 334 "shr edx, 16" \ 335 parm [ax cx] nomemory \ 336 value [ax dx] \ 337 modify exact [ax bx cx dx] nomemory; 325 parm [ecx] nomemory \ 326 value [edx] \ 327 modify exact [eax edx] nomemory; 338 328 339 329 340 330 #pragma aux ASMGetDR0 = \ 341 331 "mov eax, dr0" \ 342 "mov edx, eax" \ 343 "shr edx, 16" \ 344 parm [] nomemory \ 345 value [ax dx] \ 346 modify exact [ax dx] nomemory; 332 parm [] nomemory \ 333 value [eax] \ 334 modify exact [eax] nomemory; 347 335 348 336 #pragma aux ASMGetDR1 = \ 349 337 "mov eax, dr1" \ 350 "mov edx, eax" \ 351 "shr edx, 16" \ 352 parm [] nomemory \ 353 value [ax dx] \ 354 modify exact [ax dx] nomemory; 338 parm [] nomemory \ 339 value [eax] \ 340 modify exact [eax] nomemory; 355 341 356 342 #pragma aux ASMGetDR2 = \ 357 343 "mov eax, dr2" \ 358 "mov edx, eax" \ 359 "shr edx, 16" \ 360 parm [] nomemory \ 361 value [ax dx] \ 362 modify exact [ax dx] nomemory; 344 parm [] nomemory \ 345 value [eax] \ 346 modify exact [eax] nomemory; 363 347 364 348 #pragma aux ASMGetDR3 = \ 365 349 "mov eax, dr3" \ 366 "mov edx, eax" \ 367 "shr edx, 16" \ 368 parm [] nomemory \ 369 value [ax dx] \ 370 modify exact [ax dx] nomemory; 350 parm [] nomemory \ 351 value [eax] \ 352 modify exact [eax] nomemory; 371 353 372 354 #pragma aux ASMGetDR6 = \ 373 355 "mov eax, dr6" \ 374 "mov edx, eax" \ 375 "shr edx, 16" \ 376 parm [] nomemory \ 377 value [ax dx] \ 378 modify exact [ax dx] nomemory; 356 parm [] nomemory \ 357 value [eax] \ 358 modify exact [eax] nomemory; 379 359 380 360 #pragma aux ASMGetAndClearDR6 = \ … … 382 362 "mov eax, dr6" \ 383 363 "mov dr6, edx" \ 384 "mov edx, eax" \ 385 "shr edx, 16" \ 386 parm [] nomemory \ 387 value [ax dx] \ 388 modify exact [ax dx] nomemory; 364 parm [] nomemory \ 365 value [eax] \ 366 modify exact [eax edx] nomemory; 389 367 390 368 #pragma aux ASMGetDR7 = \ 391 369 "mov eax, dr7" \ 392 "mov edx, eax" \ 393 "shr edx, 16" \ 394 parm [] nomemory \ 395 value [ax dx] \ 396 modify exact [ax dx] nomemory; 370 parm [] nomemory \ 371 value [eax] \ 372 modify exact [eax] nomemory; 397 373 398 374 #pragma aux ASMSetDR0 = \ 399 "shl edx, 16" \ 400 "mov dx, ax" \ 401 "mov dr0, edx" \ 402 parm [ax dx] nomemory \ 403 modify exact [dx] nomemory; 375 "mov dr0, eax" \ 376 parm [eax] nomemory \ 377 modify exact [] nomemory; 404 378 405 379 #pragma aux ASMSetDR1 = \ 406 "shl edx, 16" \ 407 "mov dx, ax" \ 408 "mov dr1, edx" \ 409 parm [ax dx] nomemory \ 410 modify exact [dx] nomemory; 380 "mov dr1, eax" \ 381 parm [eax] nomemory \ 382 modify exact [] nomemory; 411 383 412 384 #pragma aux ASMSetDR2 = \ 413 "shl edx, 16" \ 414 "mov dx, ax" \ 415 "mov dr2, edx" \ 416 parm [ax dx] nomemory \ 417 modify exact [dx] nomemory; 385 "mov dr2, eax" \ 386 parm [eax] nomemory \ 387 modify exact [] nomemory; 418 388 419 389 #pragma aux ASMSetDR3 = \ 420 "shl edx, 16" \ 421 "mov dx, ax" \ 422 "mov dr3, edx" \ 423 parm [ax dx] nomemory \ 424 modify exact [dx] nomemory; 390 "mov dr3, eax" \ 391 parm [eax] nomemory \ 392 modify exact [] nomemory; 425 393 426 394 #pragma aux ASMSetDR6 = \ 427 "shl edx, 16" \ 428 "mov dx, ax" \ 429 "mov dr6, edx" \ 430 parm [ax dx] nomemory \ 431 modify exact [dx] nomemory; 395 "mov dr6, eax" \ 396 parm [eax] nomemory \ 397 modify exact [] nomemory; 432 398 433 399 #pragma aux ASMSetDR7 = \ 434 "shl edx, 16" \ 435 "mov dx, ax" \ 436 "mov dr7, edx" \ 437 parm [ax dx] nomemory \ 438 modify exact [dx] nomemory; 400 "mov dr7, eax" \ 401 parm [eax] nomemory \ 402 modify exact [] nomemory; 439 403 440 404 /* Yeah, could've used outp here, but this keeps the main file simpler. */ … … 462 426 463 427 #pragma aux ASMOutU32 = \ 464 "shl ecx, 16" \465 "mov cx, ax" \466 "mov eax, ecx" \467 428 "out dx, eax" \ 468 parm [dx] [ ax cx] nomemory \429 parm [dx] [eax] nomemory \ 469 430 modify exact [] nomemory; 470 431 471 432 #pragma aux ASMInU32 = \ 472 433 "in eax, dx" \ 473 "mov ecx, eax" \474 "shr ecx, 16" \475 434 parm [dx] nomemory \ 476 value [ ax cx] \435 value [eax] \ 477 436 modify exact [] nomemory; 478 437 479 438 #pragma aux ASMOutStrU8 = \ 480 "mov ds, bx" \481 439 "rep outsb" \ 482 parm [dx] [ bx si] [cx] nomemory \483 modify exact [ si cx ds] nomemory;440 parm [dx] [esi] [ecx] nomemory \ 441 modify exact [esi ecx] nomemory; 484 442 485 443 #pragma aux ASMInStrU8 = \ 486 444 "rep insb" \ 487 parm [dx] [e s di] [cx] \488 modify exact [ dicx];445 parm [dx] [edi] [ecx] \ 446 modify exact [edi ecx]; 489 447 490 448 #pragma aux ASMOutStrU16 = \ 491 "mov ds, bx" \492 449 "rep outsw" \ 493 parm [dx] [ bx si] [cx] nomemory \494 modify exact [ si cx ds] nomemory;450 parm [dx] [esi] [ecx] nomemory \ 451 modify exact [esi ecx] nomemory; 495 452 496 453 #pragma aux ASMInStrU16 = \ 497 454 "rep insw" \ 498 parm [dx] [e s di] [cx] \499 modify exact [ dicx];455 parm [dx] [edi] [ecx] \ 456 modify exact [edi ecx]; 500 457 501 458 #pragma aux ASMOutStrU32 = \ 502 "mov ds, bx" \503 459 "rep outsd" \ 504 parm [dx] [ bx si] [cx] nomemory \505 modify exact [ si cx ds] nomemory;460 parm [dx] [esi] [ecx] nomemory \ 461 modify exact [esi ecx] nomemory; 506 462 507 463 #pragma aux ASMInStrU32 = \ 508 464 "rep insd" \ 509 parm [dx] [es di] [cx] \ 510 modify exact [di cx]; 511 512 /* ASMInvalidatePage: When needed. */ 465 parm [dx] [edi] [ecx] \ 466 modify exact [edi ecx]; 467 468 #pragma aux ASMInvalidatePage = \ 469 "invlpg [eax]" \ 470 parm [eax] \ 471 modify exact []; 513 472 514 473 #pragma aux ASMWriteBackAndInvalidateCaches = \
Note:
See TracChangeset
for help on using the changeset viewer.