Changeset 101546 in vbox
- Timestamp:
- Oct 23, 2023 12:50:04 AM (18 months ago)
- svn:sync-xref-src-repo-rev:
- 159623
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/dis.h
r101540 r101546 505 505 506 506 507 /** @name Flags for use with DISFormatYasmEx(), DISFormatMasmEx() and DISFormatGasEx(). 507 /** @name Flags for use with DISFormatYasmEx(), DISFormatMasmEx(), 508 * DISFormatGasEx() and DISFormatArmV8Ex(). 508 509 * @{ 509 510 */ … … 526 527 /** Put spaces between the bytes. */ 527 528 #define DIS_FMT_FLAGS_BYTES_SPACED RT_BIT_32(7) 529 /** Gives the width (in opcode bytes) of the opcode bytes area if on the left 530 * side. If zero, then a default of 7 will be used. */ 531 #define DIS_FMT_FLAGS_BYTES_WIDTH_MASK UINT32_C(0x00001f00) 532 /** Shift count of the bytes width field. */ 533 #define DIS_FMT_FLAGS_BYTES_WIDTH_SHIFT 8 534 /** Helper that makes shift the width count. */ 535 #define DIS_FMT_FLAGS_BYTES_WIDTH_MAKE(a_cb) ((uint32_t)(a_cb) << DIS_FMT_FLAGS_BYTES_WIDTH_SHIFT) 528 536 /** Display the relative +/- offset of branch instructions that uses relative addresses, 529 537 * and put the target address in parenthesis. */ 530 #define DIS_FMT_FLAGS_RELATIVE_BRANCH RT_BIT_32( 8)538 #define DIS_FMT_FLAGS_RELATIVE_BRANCH RT_BIT_32(13) 531 539 /** Strict assembly. The assembly should, when ever possible, make the 532 540 * assembler reproduce the exact same binary. (Refers to the yasm 533 541 * strict keyword.) */ 534 #define DIS_FMT_FLAGS_STRICT RT_BIT_32(9) 542 #define DIS_FMT_FLAGS_STRICT RT_BIT_32(14) 543 /** C-style hex formatting (0x01), rather than assembly style (001h). */ 544 #define DIS_FMT_FLAGS_C_HEX RT_BIT_32(15) 545 535 546 /** Checks if the given flags are a valid combination. */ 536 547 #define DIS_FMT_FLAGS_IS_VALID(fFlags) \ 537 ( !((fFlags) & ~UINT32_C(0x0000 03ff)) \548 ( !((fFlags) & ~UINT32_C(0x0000ffff)) \ 538 549 && ((fFlags) & (DIS_FMT_FLAGS_ADDR_RIGHT | DIS_FMT_FLAGS_ADDR_LEFT)) != (DIS_FMT_FLAGS_ADDR_RIGHT | DIS_FMT_FLAGS_ADDR_LEFT) \ 539 550 && ( !((fFlags) & DIS_FMT_FLAGS_ADDR_COMMENT) \ -
trunk/src/VBox/Disassembler/DisasmFormatYasm.cpp
r101539 r101546 367 367 } \ 368 368 } while (0) 369 /** @todo add two flags for choosing between %X / %x and h / 0x. */ 370 #define PUT_NUM_8(num) PUT_NUM(4, "0%02xh", (uint8_t)(num)) 371 #define PUT_NUM_16(num) PUT_NUM(6, "0%04xh", (uint16_t)(num)) 372 #define PUT_NUM_32(num) PUT_NUM(10, "0%08xh", (uint32_t)(num)) 373 #define PUT_NUM_64(num) PUT_NUM(18, "0%016RX64h", (uint64_t)(num)) 369 #define PUT_NUM_8(num) PUT_NUM(4, !(fFlags & DIS_FMT_FLAGS_C_HEX) ? "0%02xh" : "%#04x", (uint8_t)(num)) 370 #define PUT_NUM_16(num) PUT_NUM(6, !(fFlags & DIS_FMT_FLAGS_C_HEX) ? "0%04xh" : "%#06x", (uint16_t)(num)) 371 #define PUT_NUM_32(num) PUT_NUM(10, !(fFlags & DIS_FMT_FLAGS_C_HEX) ? "0%08xh" : "%#010x", (uint32_t)(num)) 372 #define PUT_NUM_64(num) PUT_NUM(18, !(fFlags & DIS_FMT_FLAGS_C_HEX) ? "0%016RX64h" : "%#018RX64", (uint64_t)(num)) 374 373 375 374 #define PUT_NUM_SIGN(cch, fmt, num, stype, utype) \ … … 386 385 } \ 387 386 } while (0) 388 #define PUT_NUM_S8(num) PUT_NUM_SIGN(4, "0%02xh",num, int8_t, uint8_t)389 #define PUT_NUM_S16(num) PUT_NUM_SIGN(6, "0%04xh",num, int16_t, uint16_t)390 #define PUT_NUM_S32(num) PUT_NUM_SIGN(10, "0%08xh",num, int32_t, uint32_t)391 #define PUT_NUM_S64(num) PUT_NUM_SIGN(18, "0%016RX64h", num, int64_t, uint64_t)387 #define PUT_NUM_S8(num) PUT_NUM_SIGN(4, !(fFlags & DIS_FMT_FLAGS_C_HEX) ? "0%02xh" : "%#04x", num, int8_t, uint8_t) 388 #define PUT_NUM_S16(num) PUT_NUM_SIGN(6, !(fFlags & DIS_FMT_FLAGS_C_HEX) ? "0%04xh" : "%#06x", num, int16_t, uint16_t) 389 #define PUT_NUM_S32(num) PUT_NUM_SIGN(10, !(fFlags & DIS_FMT_FLAGS_C_HEX) ? "0%08xh" : "%#010x", num, int32_t, uint32_t) 390 #define PUT_NUM_S64(num) PUT_NUM_SIGN(18, !(fFlags & DIS_FMT_FLAGS_C_HEX) ? "0%016RX64h" : "%#018RX64", num, int64_t, uint64_t) 392 391 393 392 #define PUT_SYMBOL_TWO(a_rcSym, a_szStart, a_chEnd) \ … … 457 456 458 457 /* Some padding to align the instruction. */ 459 size_t cchPadding = (7 * (2 + !!(fFlags & DIS_FMT_FLAGS_BYTES_SPACED))) 458 uint32_t cbWidth = (fFlags & DIS_FMT_FLAGS_BYTES_WIDTH_MASK) >> DIS_FMT_FLAGS_BYTES_WIDTH_SHIFT; 459 if (!cbWidth) 460 cbWidth = 7; 461 size_t cchPadding = (cbWidth * (2 + !!(fFlags & DIS_FMT_FLAGS_BYTES_SPACED))) 460 462 + !!(fFlags & DIS_FMT_FLAGS_BYTES_BRACKETS) * 2 461 463 + 2; … … 595 597 { 596 598 Assert(pDis->cbInstr >= 3); 597 PUT_SZ("db 00fh, 01fh,"); 598 PUT_NUM_8(MAKE_MODRM(pDis->x86.ModRM.Bits.Mod, pDis->x86.ModRM.Bits.Reg, pDis->x86.ModRM.Bits.Rm)); 599 for (unsigned i = 3; i < pDis->cbInstr; i++) 599 PUT_SZ("db 00fh, 01fh"); 600 for (unsigned off = 2; off < pDis->cbInstr; off++) 600 601 { 601 602 PUT_C(','); 602 PUT_NUM_8(0x90); /// @todo fixme. 603 PUT_C(' '); 604 PUT_NUM_8(pDis->Instr.ab[off]); 603 605 } 604 606 pszFmt = "";
Note:
See TracChangeset
for help on using the changeset viewer.