Changeset 8352 in vbox for trunk/src/VBox
- Timestamp:
- Apr 24, 2008 9:50:26 AM (17 years ago)
- Location:
- trunk/src/VBox/Disassembler
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Disassembler/DisasmCore.cpp
r8336 r8352 270 270 { 271 271 pCpu->lastprefix = opcode; 272 273 /* The REX prefix must precede the opcode byte(s). Any other placement is ignored. */ 274 if (opcode != OP_REX) 275 pCpu->prefix &= ~PREFIX_REX; 276 272 277 switch (opcode) 273 278 { … … 324 329 pCpu->prefix |= PREFIX_REX; 325 330 pCpu->prefix_rex = PREFIX_REX_OP_2_FLAGS(opcode); 331 332 if (pCpu->prefix_rex & PREFIX_REX_FLAGS_W) 333 pCpu->opmode = CPUMODE_64BIT; /* overrides size prefix byte */ 326 334 break; 327 335 } … … 537 545 if (pCpu->prefix & PREFIX_REX) 538 546 { 539 pCpu->SIB.Bits.Base |= ((!!(pCpu->prefix_rex & PREFIX_REX_FLAGS_B)) << 3); 547 /* REX.B extends the Base field if not scaled index + disp32 */ 548 if (!(pCpu->SIB.Bits.Base == 5 && pCpu->ModRM.Bits.Mod == 0)) 549 pCpu->SIB.Bits.Base |= ((!!(pCpu->prefix_rex & PREFIX_REX_FLAGS_B)) << 3); 550 540 551 pCpu->SIB.Bits.Index |= ((!!(pCpu->prefix_rex & PREFIX_REX_FLAGS_X)) << 3); 541 552 } … … 651 662 } 652 663 653 //TODO: bound 654 655 if (pCpu->addrmode == CPUMODE_32BIT) 656 {//32 bits addressing mode 664 /* @todo bound */ 665 666 if (pCpu->addrmode != CPUMODE_16BIT) 667 { 668 Assert(pCpu->addrmode == CPUMODE_32BIT || pCpu->addrmode == CPUMODE_64BIT); 669 670 /* 671 * Note: displacements in long mode are 8 or 32 bits and sign-extended to 64 bits 672 */ 657 673 switch (mod) 658 674 { … … 660 676 disasmGetPtrString(pCpu, pOp, pParam); 661 677 disasmAddChar(pParam->szParam, '['); 662 if (rm == 4) {//SIB byte follows ModRM 678 if (rm == 4) 679 { /* SIB byte follows ModRM */ 663 680 UseSIB(lpszCodeBlock, pOp, pParam, pCpu); 664 681 } 665 682 else 666 if (rm == 5) {//32 bits displacement 667 pParam->flags |= USE_DISPLACEMENT32; 668 pParam->disp32 = pCpu->disp; 669 disasmPrintDisp32(pParam); 683 if (rm == 5) 684 { 685 /* 32 bits displacement */ 686 if (pCpu->mode == CPUMODE_32BIT) 687 { 688 pParam->flags |= USE_DISPLACEMENT32; 689 pParam->disp32 = pCpu->disp; 690 disasmPrintDisp32(pParam); 691 } 692 else 693 { 694 pParam->flags |= USE_RIPDISPLACEMENT32; 695 pParam->disp32 = pCpu->disp; 696 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "RIP+"); 697 disasmPrintDisp32(pParam); 698 } 670 699 } 671 700 else {//register address … … 967 996 if (pCpu->prefix & PREFIX_REX) 968 997 { 998 Assert(pCpu->mode == CPUMODE_64BIT); 999 969 1000 /* REX.R extends the Reg field. */ 970 1001 pCpu->ModRM.Bits.Reg |= ((!!(pCpu->prefix_rex & PREFIX_REX_FLAGS_R)) << 3); 971 1002 972 /* REX.B extends the Rm field if there is no SIB byte. */ 973 if ( pCpu->ModRM.Bits.Mod != 3 974 && pCpu->ModRM.Bits.Rm == 4) 1003 /* REX.B extends the Rm field if there is no SIB byte nor a 32 bits displacement */ 1004 if (!( pCpu->ModRM.Bits.Mod != 3 1005 && pCpu->ModRM.Bits.Rm == 4) 1006 && 1007 !( pCpu->ModRM.Bits.Mod == 0 1008 && pCpu->ModRM.Bits.Rm == 5)) 975 1009 { 976 1010 pCpu->ModRM.Bits.Rm |= ((!!(pCpu->prefix_rex & PREFIX_REX_FLAGS_B)) << 3); … … 981 1015 982 1016 UseModRM(lpszCodeBlock, pOp, pParam, pCpu); 983 984 1017 return size; 985 1018 } … … 1000 1033 if (pCpu->prefix & PREFIX_REX) 1001 1034 { 1035 Assert(pCpu->mode == CPUMODE_64BIT); 1036 1002 1037 /* REX.R extends the Reg field. */ 1003 1038 pCpu->ModRM.Bits.Reg |= ((!!(pCpu->prefix_rex & PREFIX_REX_FLAGS_R)) << 3); 1004 1039 1005 /* REX.B extends the Rm field if there is no SIB byte. */ 1006 if ( pCpu->ModRM.Bits.Mod != 3 1007 && pCpu->ModRM.Bits.Rm == 4) 1040 /* REX.B extends the Rm field if there is no SIB byte nor a 32 bits displacement */ 1041 if (!( pCpu->ModRM.Bits.Mod != 3 1042 && pCpu->ModRM.Bits.Rm == 4) 1043 && 1044 !( pCpu->ModRM.Bits.Mod == 0 1045 && pCpu->ModRM.Bits.Rm == 5)) 1008 1046 { 1009 1047 pCpu->ModRM.Bits.Rm |= ((!!(pCpu->prefix_rex & PREFIX_REX_FLAGS_B)) << 3); … … 1305 1343 } 1306 1344 1345 AssertCompile(OP_PARM_REG_GEN32_END < OP_PARM_REG_SEG_END); 1346 AssertCompile(OP_PARM_REG_SEG_END < OP_PARM_REG_GEN16_END); 1347 AssertCompile(OP_PARM_REG_GEN16_END < OP_PARM_REG_GEN8_END); 1348 AssertCompile(OP_PARM_REG_GEN8_END < OP_PARM_REG_FP_END); 1349 1307 1350 if (pParam->param <= OP_PARM_REG_GEN32_END) 1308 1351 { 1309 1352 /* 32-bit EAX..EDI registers. */ 1310 1311 1353 if (pCpu->opmode == CPUMODE_32BIT) 1312 1354 { … … 1369 1411 pParam->size = 10; 1370 1412 } 1413 Assert(!(pParam->param >= OP_PARM_REG_GEN64_START && pParam->param <= OP_PARM_REG_GEN64_END)); 1414 1371 1415 /* else - not supported for now registers. */ 1372 1416 … … 1936 1980 else 1937 1981 if (subtype == OP_PARM_v || subtype == OP_PARM_NONE) 1938 subtype = (pCpu->opmode == CPUMODE_32BIT) ? OP_PARM_d : OP_PARM_w; 1982 { 1983 switch(pCpu->opmode) 1984 { 1985 case CPUMODE_32BIT: 1986 subtype = OP_PARM_d; 1987 break; 1988 case CPUMODE_64BIT: 1989 subtype = OP_PARM_q; 1990 break; 1991 case CPUMODE_16BIT: 1992 subtype = OP_PARM_w; 1993 break; 1994 } 1995 } 1939 1996 1940 1997 switch (subtype) … … 1955 2012 disasmAddString(pParam->szParam, szModRMReg32[idx]); 1956 2013 pParam->flags |= USE_REG_GEN32; 2014 pParam->base.reg_gen = idx; 2015 break; 2016 2017 case OP_PARM_q: 2018 disasmAddString(pParam->szParam, szModRMReg64[idx]); 2019 pParam->flags |= USE_REG_GEN64; 1957 2020 pParam->base.reg_gen = idx; 1958 2021 break; -
trunk/src/VBox/Disassembler/DisasmTablesX64.cpp
r8299 r8352 174 174 175 175 /* 5 */ 176 OP("push %eAX", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ RAX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),177 OP("push %eCX", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ RCX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),178 OP("push %eDX", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ RDX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),179 OP("push %eBX", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ RBX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),180 OP("push %eSP", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ RSP, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),181 OP("push %eBP", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ RBP, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),182 OP("push %eSI", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ RSI, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),183 OP("push %eDI", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ RDI, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),184 OP("pop %eAX", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ RAX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),185 OP("pop %eCX", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ RCX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),186 OP("pop %eDX", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ RDX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),187 OP("pop %eBX", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ RBX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),188 OP("pop %eSP", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ RSP, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),189 OP("pop %eBP", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ RBP, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),190 OP("pop %eSI", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ RSI, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),191 OP("pop %eDI", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ RDI, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE),176 OP("push %eAX", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_EAX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 177 OP("push %eCX", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ECX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 178 OP("push %eDX", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_EDX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 179 OP("push %eBX", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_EBX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 180 OP("push %eSP", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ESP, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 181 OP("push %eBP", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_EBP, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 182 OP("push %eSI", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_ESI, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 183 OP("push %eDI", IDX_ParseFixedReg, 0, 0, OP_PUSH, OP_PARM_REG_EDI, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 184 OP("pop %eAX", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_EAX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 185 OP("pop %eCX", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ECX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 186 OP("pop %eDX", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_EDX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 187 OP("pop %eBX", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_EBX, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 188 OP("pop %eSP", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ESP, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 189 OP("pop %eBP", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_EBP, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 190 OP("pop %eSI", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_ESI, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 191 OP("pop %eDI", IDX_ParseFixedReg, 0, 0, OP_POP, OP_PARM_REG_EDI, OP_PARM_NONE, OP_PARM_NONE, OPTYPE_HARMLESS | OPTYPE_DEFAULT_64_OP_SIZE), 192 192 193 193 /* 6 */
Note:
See TracChangeset
for help on using the changeset viewer.