Changeset 102201 in vbox
- Timestamp:
- Nov 21, 2023 1:15:33 PM (17 months ago)
- svn:sync-xref-src-repo-rev:
- 160326
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-3-high-asm.asm
r102183 r102201 78 78 dq 0 79 79 80 %ifdef WITH_TRACING 80 81 BS3_GLOBAL_DATA g_bs3CpuBasic3_lea_trace, 4 81 82 dd 0 83 %endif 82 84 83 85 ; … … 94 96 export BS3_CMN_NM(bs3CpuBasic3_lea_64) 95 97 BS3_PROC_BEGIN_CMN bs3CpuBasic3_lea_64, BS3_PBC_NEAR 96 %if 097 times 512-0x1a db 198 %assign x 199 %rep 167100 %assign x x+1101 times 512 db x102 %endrep103 %else104 98 push rax 105 99 push rcx … … 123 117 ; Loop thru all the modr/m memory encodings. 124 118 ; 125 %assign iMod0126 %assign iDstReg 0 ; We don't test all destination registers 127 % rep 3128 %rep 16 ; Destination registers per encoding. Testing all takes too much space.129 %assign iMemReg0130 131 132 133 134 119 %assign iMod 0 120 %rep 3 121 %assign iDstReg 0 122 %rep 16 123 %assign iMemReg 0 124 %rep 16 125 %assign iDstReg_Value %sel(iDstReg+1, LEA_RAX, LEA_RCX, LEA_RDX, LEA_RBX, LEA_RSP, LEA_RBP, LEA_RSI, LEA_RDI, \ 126 LEA_R8, LEA_R9, LEA_R10, LEA_R11, LEA_R12, LEA_R13, LEA_R14, LEA_R15) 127 128 %if (iMemReg & 7) == 4 135 129 ; 136 130 ; SIB. 137 131 ; 138 139 140 141 142 143 144 145 146 147 148 149 150 %assign iBase_Value %sel(iIndex+1, LEA_RAX, LEA_RCX, LEA_RDX, LEA_RBX, 0, LEA_RBP, LEA_RSI, LEA_RDI, \151 132 %assign iBase 0 133 %rep 16 134 %if (iBase & 7) == 5 && iMod == 0 135 %assign iBase_Value 0 136 %else 137 %assign iBase_Value %sel(iBase+1, LEA_RAX, LEA_RCX, LEA_RDX, LEA_RBX, LEA_RSP, LEA_RBP, LEA_RSI, LEA_RDI, \ 138 LEA_R8, LEA_R9, LEA_R10, LEA_R11, LEA_R12, LEA_R13, LEA_R14, LEA_R15) 139 %endif 140 141 %assign iIndex 0 142 %assign cShift 0 ; we don't have enough room for checking all the shifts. 143 %rep 16 144 %assign iIndex_Value %sel(iIndex+1, LEA_RAX, LEA_RCX, LEA_RDX, LEA_RBX, 0, LEA_RBP, LEA_RSI, LEA_RDI, \ 145 LEA_R8, LEA_R9, LEA_R10, LEA_R11, LEA_R12, LEA_R13, LEA_R14, LEA_R15) 152 146 153 147 ; … … 155 149 ; in the image for that. 156 150 ; 157 %assign cShiftLoops 0 ; Disabled for now158 159 %error asdf 151 %assign cShiftLoops 4 152 %rep cShiftLoops 153 160 154 ; 161 155 ; LEA+SIB w/ 64-bit operand size and 64-bit address size. 162 156 ; 157 %ifdef WITH_TRACING 158 mov dword [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_trace))], $ 159 %endif 163 160 call .load_regs 164 161 %if iBase == 4 || iDstReg == 4 165 162 mov rsp, LEA_RSP 166 163 %endif 167 164 168 165 ; lea 169 170 db X86_OP_REX_W | ((iBase & 8) >> 3) | ((iIndex & 8) >> 2) | ((iDstReg ) & 8>> 1)166 %assign iValue iBase_Value + (iIndex_Value << cShift) 167 db X86_OP_REX_W | ((iBase & 8) >> 3) | ((iIndex & 8) >> 2) | ((iDstReg & 8) >> 1) 171 168 db 8dh, X86_MODRM_MAKE(iMod, iDstReg & 7, iMemReg & 7), X86_SIB_MAKE(iBase & 7, iIndex & 7, cShift) 172 169 %if iMod == X86_MOD_MEM1 173 170 db -128 174 175 %elif iMod == X86_MOD_MEM4 || (iMod == 0 && iBase== 5)176 dd -07ff fffffh177 %assign iValue iValue - 07fffffffh178 171 %assign iValue iValue - 128 172 %elif iMod == X86_MOD_MEM4 || (iMod == 0 && (iBase & 7) == 5) 173 dd -07ffef3ffh 174 %assign iValue iValue - 07ffef3ffh 175 %endif 179 176 180 177 ; cmp iDstReg, iValue 181 178 %if iValue <= 07fffffffh && iValue >= -080000000h 182 179 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 183 180 db 81h, X86_MODRM_MAKE(X86_MOD_REG, 7, iDstReg & 7) 184 181 dd iValue & 0ffffffffh 185 182 %elif iDstReg != X86_GREG_xAX 186 183 mov rax, iValue 187 184 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 188 185 db 39h, X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xAX, iDstReg & 7) 189 186 %else 190 187 mov rcx, iValue 191 188 cmp rax, rcx 192 %endif 193 %if iDstReg == 4 194 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 195 %endif 189 %endif 190 %if iBase == 4 || iDstReg == 4 191 mov rdx, rsp 192 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 193 %endif 196 194 jz $+3 197 195 int3 198 %assign cShift (cShift + 1) & 3 199 200 201 202 203 204 205 206 196 197 %assign cShift (cShift + 1) & 3 198 %endrep 199 %assign iIndex iIndex + 1 200 %endrep 201 %assign iBase iBase + 1 202 %endrep 203 204 %else ; !SIB 207 205 ; 208 206 ; Plain lea reg, [reg] with disp according to iMod, 209 207 ; or lea reg, [disp32] if iMemReg == 5 && iMod == 0. 210 208 ; 211 212 213 214 215 216 209 %if (iMemReg & 7) == 5 && iMod == 0 210 %assign iMemReg_Value 0 211 %else 212 %assign iMemReg_Value %sel(iMemReg+1, LEA_RAX, LEA_RCX, LEA_RDX, LEA_RBX, LEA_RSP, LEA_RBP, LEA_RSI, LEA_RDI, \ 213 LEA_R8, LEA_R9, LEA_R10, LEA_R11, LEA_R12, LEA_R13, LEA_R14, LEA_R15) 214 %endif 217 215 218 216 ; 219 217 ; 64-bit operand and address size first. 220 218 ; 221 ;mov eax, $ 222 mov dword [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_trace))], $ ;iMod | (iDstReg << 4) | (iMemReg << 8) 223 219 %ifdef WITH_TRACING 220 mov dword [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_trace))], $ 221 %endif 224 222 call .load_regs 225 223 %if iDstReg == 4 226 224 mov rsp, LEA_RSP 227 225 %endif 228 226 229 227 ; lea 230 228 %assign iValue iMemReg_Value 231 229 db X86_OP_REX_W | ((iDstReg & 8) >> 1) | ((iMemReg & 8) >> 3) 232 230 db 8dh, X86_MODRM_MAKE(iMod, iDstReg & 7, iMemReg & 7) 233 231 %if iMod == X86_MOD_MEM1 234 232 db 39 235 236 233 %assign iValue iValue + 39 234 %elif iMod == 0 && (iMemReg & 7) == 5 237 235 dd .load_regs - $ - 4 238 236 %elif iMod == X86_MOD_MEM4 239 237 dd 058739af8h 240 241 238 %assign iValue iValue + 058739af8h 239 %endif 242 240 243 241 ; cmp iDstReg, iValue 244 242 %if (iValue <= 07fffffffh && iValue >= -080000000h) || (iMod == 0 && (iMemReg & 7) == 5) 245 243 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 246 244 db 81h, X86_MODRM_MAKE(X86_MOD_REG, 7, iDstReg & 7) 247 245 %if iMod == 0 && (iMemReg & 7) == 5 248 246 dd .load_regs wrt BS3FLAT 249 247 %else 250 248 dd iValue & 0ffffffffh 251 252 253 249 %endif 250 %else 251 %if iDstReg != iMemReg && iValue == iMemReg_Value ; This isn't entirely safe, but it saves a bit of space. 254 252 db X86_OP_REX_W | ((iDstReg & 8) >> 1) | ((iMemReg & 8) >> 3) 255 253 db 39h, X86_MODRM_MAKE(X86_MOD_REG, iDstReg & 7, iMemReg & 7) 256 254 %elif iDstReg != X86_GREG_xAX 257 255 mov rax, iValue 258 db X86_OP_REX_W | ((iDstReg & 8) >> 3)256 db (X86_OP_REX_W | ((iDstReg & 8) >> 3)) 259 257 db 39h, X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xAX, iDstReg & 7) 260 258 %else 261 259 mov rcx, iValue 262 260 cmp rax, rcx 263 264 265 266 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 267 261 %endif 262 %endif 263 %if iDstReg == 4 264 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 265 %endif 268 266 jz $+3 269 267 int3 … … 273 271 ; 274 272 call .load_regs 275 273 %if iDstReg == 4 276 274 mov rsp, LEA_RSP 277 275 %endif 278 276 279 277 ; lea 280 278 %assign iValue iMemReg_Value 281 279 db X86_OP_PRF_SIZE_ADDR 282 280 db X86_OP_REX_W | ((iDstReg & 8) >> 1) | ((iMemReg & 8) >> 3) 283 281 db 8dh, X86_MODRM_MAKE(iMod, iDstReg & 7, iMemReg & 7) 284 282 %if iMod == X86_MOD_MEM1 285 283 db -92 286 287 284 %assign iValue iValue - 92 285 %elif iMod == 0 && (iMemReg & 7) == 5 288 286 dd .test_label - $ - 4 289 287 %elif iMod == X86_MOD_MEM4 290 288 dd -038f8acf3h 291 292 293 289 %assign iValue iValue - 038f8acf3h 290 %endif 291 %assign iValue iValue & 0ffffffffh 294 292 295 293 ; cmp iDstReg, iValue 296 294 %if (iValue <= 07fffffffh && iValue >= 0) || (iMod == 0 && (iMemReg & 7) == 5) 297 295 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 298 296 db 81h, X86_MODRM_MAKE(X86_MOD_REG, 7, iDstReg & 7) 299 297 %if iMod == 0 && (iMemReg & 7) == 5 300 298 dd .test_label wrt BS3FLAT 301 299 %else 302 300 dd iValue 303 304 305 301 %endif 302 %else 303 %if iDstReg != X86_GREG_xAX 306 304 mov eax, iValue 305 ;cmp eax, %sel(iDstReg+1, rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15) 307 306 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 308 307 db 39h, X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xAX, iDstReg & 7) 309 308 %else 310 309 mov ecx, iValue 311 310 cmp rax, rcx 312 313 314 315 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 316 311 %endif 312 %endif 313 %if iDstReg == 4 314 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 315 %endif 317 316 jz $+3 318 317 int3 … … 322 321 ; 323 322 call .load_regs 324 323 %if iDstReg == 4 325 324 mov rsp, LEA_RSP 326 325 %endif 327 326 328 327 ; lea 329 330 328 %assign iValue iMemReg_Value 329 %if iDstReg >= 8 || iMemReg >= 8 331 330 db X86_OP_REX | ((iDstReg & 8) >> 1) | ((iMemReg & 8) >> 3) 332 331 %endif 333 332 db 8dh, X86_MODRM_MAKE(iMod, iDstReg & 7, iMemReg & 7) 334 333 %if iMod == X86_MOD_MEM1 335 334 db 16 336 337 335 %assign iValue iValue + 16 336 %elif iMod == 0 && (iMemReg & 7) == 5 338 337 dd .load_regs - $ - 4 339 338 %elif iMod == X86_MOD_MEM4 340 339 dd 0596829deh 341 342 343 340 %assign iValue iValue + 0596829deh 341 %endif 342 %assign iValue iValue & 0ffffffffh 344 343 345 344 ; cmp iDstReg, iValue 346 345 %if (iValue <= 07fffffffh && iValue >= 0) || (iMod == 0 && (iMemReg & 7) == 5) 347 346 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 348 347 db 81h, X86_MODRM_MAKE(X86_MOD_REG, 7, iDstReg & 7) 349 348 %if iMod == 0 && (iMemReg & 7) == 5 350 349 dd .load_regs wrt BS3FLAT 351 350 %else 352 351 dd iValue 353 354 355 352 %endif 353 %else 354 %if iDstReg != X86_GREG_xAX 356 355 mov eax, iValue 357 356 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 358 357 db 39h, X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xAX, iDstReg & 7) 359 358 %else 360 359 mov ecx, iValue 361 360 cmp rax, rcx 362 363 364 365 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 366 361 %endif 362 %endif 363 %if iDstReg == 4 364 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 365 %endif 367 366 jz $+3 368 367 int3 … … 372 371 ; 373 372 call .load_regs 374 373 %if iDstReg == 4 375 374 mov rsp, LEA_RSP 376 375 %endif 377 376 378 377 ; lea 379 378 %assign iValue iMemReg_Value 380 379 db X86_OP_PRF_SIZE_OP 381 380 %if iDstReg >= 8 || iMemReg >= 8 382 381 db X86_OP_REX | ((iDstReg & 8) >> 1) | ((iMemReg & 8) >> 3) 383 382 %endif 384 383 db 8dh, X86_MODRM_MAKE(iMod, iDstReg & 7, iMemReg & 7) 385 384 %if iMod == X86_MOD_MEM1 386 385 db -16 387 388 386 %assign iValue iValue - 16 387 %elif iMod == 0 && (iMemReg & 7) == 5 389 388 dd _Bs3Text16_StartOfSegment - $ - 4 + 7 wrt BS3FLAT 390 391 389 %assign iValue 7 390 %elif iMod == X86_MOD_MEM4 392 391 dd 075682332h 393 394 395 392 %assign iValue iValue + 075682332h 393 %endif 394 %assign iValue (iValue & 0ffffh) | (iDstReg_Value & 0ffffffffffff0000h) 396 395 397 396 ; cmp iDstReg, iValue 398 397 %if (iValue <= 07fffffffh && iValue >= -080000000h) 399 398 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 400 399 db 81h, X86_MODRM_MAKE(X86_MOD_REG, 7, iDstReg & 7) 401 400 dd iValue 402 401 %elif iDstReg != X86_GREG_xAX 403 402 mov rax, iValue 404 403 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 405 404 db 39h, X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xAX, iDstReg & 7) 406 405 %else 407 406 mov rcx, iValue 408 407 cmp rax, rcx 409 410 411 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 412 408 %endif 409 %if iDstReg == 4 410 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 411 %endif 413 412 jz $+3 414 413 int3 … … 418 417 ; 419 418 call .load_regs 420 419 %if iDstReg == 4 421 420 mov rsp, LEA_RSP 422 421 %endif 423 422 424 423 ; lea 425 424 %assign iValue iMemReg_Value 426 425 db X86_OP_PRF_SIZE_OP 427 426 db X86_OP_PRF_SIZE_ADDR 428 427 %if iDstReg >= 8 || iMemReg >= 8 429 428 db X86_OP_REX | ((iDstReg & 8) >> 1) | ((iMemReg & 8) >> 3) 430 429 %endif 431 430 db 8dh, X86_MODRM_MAKE(iMod, iDstReg & 7, iMemReg & 7) 432 431 %if iMod == X86_MOD_MEM1 433 432 db 99 434 435 433 %assign iValue iValue + 99 434 %elif iMod == 0 && (iMemReg & 7) == 5 436 435 dd _Bs3Text16_StartOfSegment - $ - 4 + 3347 wrt BS3FLAT 437 438 436 %assign iValue 3347 437 %elif iMod == X86_MOD_MEM4 439 438 dd -075623432h 440 441 442 439 %assign iValue iValue - 075623432h 440 %endif 441 %assign iValue (iValue & 0ffffh) | (iDstReg_Value & 0ffffffffffff0000h) 443 442 444 443 ; cmp iDstReg, iValue 445 444 %if (iValue <= 07fffffffh && iValue >= -080000000h) 446 445 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 447 446 db 81h, X86_MODRM_MAKE(X86_MOD_REG, 7, iDstReg & 7) 448 447 dd iValue 449 448 %elif iDstReg != X86_GREG_xAX 450 449 mov rax, iValue 451 450 db X86_OP_REX_W | ((iDstReg & 8) >> 3) 452 451 db 39h, X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xAX, iDstReg & 7) 453 452 %else 454 453 mov rcx, iValue 455 454 cmp rax, rcx 456 457 458 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 459 455 %endif 456 %if iDstReg == 4 457 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] 458 %endif 460 459 jz $+3 461 460 int3 462 461 463 %endif ; !SIB 464 %assign iMemReg iMemReg + 1 465 %endrep 466 %assign iDstReg (iDstReg + 1) & 15 462 %endif ; !SIB 463 %assign iMemReg iMemReg + 1 467 464 %endrep 468 %assign i Mod iMod+ 1465 %assign iDstReg iDstReg + 1 469 466 %endrep 467 %assign iMod iMod + 1 468 %endrep 470 469 471 470 mov rsp, [BS3_DATA16_WRT(BS3_DATA_NM(g_bs3CpuBasic3_lea_rsp))] … … 504 503 mov r15, LEA_R15 505 504 ret 506 %endif507 505 BS3_PROC_END_CMN bs3CpuBasic3_lea_64 508 506
Note:
See TracChangeset
for help on using the changeset viewer.