Skip to content

Commit a1b2e0d

Browse files
authored
X86: Fix movabsq immediates >= 2^63 printed as decimal in ATT syntax (#2843)
Fix issue #2817: In AT&T syntax, movabsq instructions with immediate values >= 2^63 (0x8000000000000000) were incorrectly printed in decimal instead of hexadecimal. Root cause: The comparison 'imm > HEX_THRESHOLD' used a signed int64_t, so values with bit 63 set appeared negative and failed the comparison. Fix: Cast imm to uint64_t for the comparison to handle the full 64-bit unsigned range correctly. Note: Regression tests for exact asm_text format cannot be added because cstest's compare_asm_text() normalizes hex/decimal representations.
1 parent 1bc76ea commit a1b2e0d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

arch/X86/X86ATTInstPrinter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,8 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
732732
case X86_INS_MOVABS:
733733
case X86_INS_MOV:
734734
// do not print number in negative form
735-
if (imm > HEX_THRESHOLD)
735+
// Use unsigned comparison to handle values >= 2^63 correctly
736+
if ((uint64_t)imm > HEX_THRESHOLD)
736737
SStream_concat(O, "$0x%" PRIx64, imm);
737738
else
738739
SStream_concat(O, "$%" PRIu64, imm);

0 commit comments

Comments
 (0)