Skip to content

x86: fix PUSH and ENTER immediate sizes - #3181

Open
ricardojrdez wants to merge 1 commit into
capstone-engine:nextfrom
reverseame:x86-push-enter-imm
Open

ricardojrdez wants to merge 1 commit into
capstone-engine:nextfrom
reverseame:x86-push-enter-imm

Conversation

@ricardojrdez

Copy link
Copy Markdown
Contributor

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

  • 6a ff (32, unsigned): the sign-extended imm8 of PUSH is now masked to
    the 32-bit operand size when printed, giving 0xffffffff instead of
    0xffffffffffffffff.
  • c8 fe fe fe (32): ENTER immediates are no longer sign-extended; they
    now print as 0xfefe and 0xfe, with sizes 2 and 1 instead of 4 and 4.

Test plan

Added 5 regression tests in tests/details/x86.yaml to cover the fix. They fail before the change.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (next@ccd25ab). Learn more about missing BASE report.

Files with missing lines Patch % Lines
arch/X86/X86ATTInstPrinter.c 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3181   +/-   ##
=======================================
  Coverage        ?   61.89%           
=======================================
  Files           ?      243           
  Lines           ?    56933           
  Branches        ?    10128           
=======================================
  Hits            ?    35236           
  Misses          ?    16492           
  Partials        ?     5205           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added the X86 Arch label Nov 25, 2026
Comment thread tests/details/x86.yaml
expected:
insns:
-
asm_text: "push 0ffffffffh"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Check operand

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just a note on the MASM test case: it now checks the operand (imm -0x1, size 4).

- 6a ff (32, unsigned): the sign-extended imm8 of PUSH is now masked to
  the 32-bit operand size when printed, giving 0xffffffff instead of
  0xffffffffffffffff.
- c8 fe fe fe (32): ENTER immediates are no longer sign-extended; they
  now print as 0xfefe and 0xfe, with sizes 2 and 1 instead of 4 and 4.

This branch has not been deployed

No deployments
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.

2 participants