Skip to content

Conversation

@0verflowme
Copy link
Contributor

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.

Added test cases for issue 2817 covering both 0x8000000000000000 and 0xffffffffffffffff in ATT syntax.

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

...

Test plan

...

Closing issues

...

@github-actions github-actions bot added the X86 Arch label Jan 7, 2026
Copy link
Collaborator

@jiegec jiegec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. By the way, the added tests does not prevent regression, and it passes on the latest next branch as well. We still need a way to match the assembly text in an exact way, as the current asm_text matcher ignores hex vs decimal differences.

Fix issue capstone-engine#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.
@0verflowme 0verflowme force-pushed the fix/issue-2817-movabsq-hex-format branch from 7001cb0 to 62f681f Compare January 7, 2026 08:39
@0verflowme
Copy link
Contributor Author

LGTM. By the way, the added tests does not prevent regression, and it passes on the latest next branch as well. We still need a way to match the assembly text in an exact way, as the current asm_text matcher ignores hex vs decimal differences.

Removed test

@Rot127 Rot127 merged commit a1b2e0d into capstone-engine:next Jan 7, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

X86 Arch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants