Skip to content

x86: fix hint NOP and CMOV operand sizes - #3185

Open
ricardojrdez wants to merge 1 commit into
capstone-engine:nextfrom
reverseame:x86-hint-nop-cmov
Open

ricardojrdez wants to merge 1 commit into
capstone-engine:nextfrom
reverseame:x86-hint-nop-cmov

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

  • 0f 1c 08 (32): 0F 1C /1 is a reserved hint NOP and now decodes as nop
    dword ptr [eax] instead of being rejected.
  • 66 0f 1c 00 (16): CLDEMOTE takes no 66 prefix, and in 16-bit mode the
    66 prefix selects a 32-bit operand, so the hint NOP operand is now
    dword instead of word.
  • f3 0f 40 00 (16): the F3 prefix no longer changes the operand size of
    CMOVO, which is word again, the 16-bit default.

Test plan

Added 8 regression tests in tests/issues/x86-mandatory-prefixes.yaml to cover the fix. 7 of them fail before the change.

@ricardojrdez

Copy link
Copy Markdown
Contributor Author

Note that #3184 also modifies the same condition in getID(). They can be merged in any order. I will rebase whichever is merged second.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines 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/X86DisassemblerDecoder.c 85.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3185   +/-   ##
=======================================
  Coverage        ?   61.87%           
=======================================
  Files           ?      243           
  Lines           ?    56938           
  Branches        ?    10133           
=======================================
  Hits            ?    35231           
  Misses          ?    16503           
  Partials        ?     5204           

☔ 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.

type: X86_OP_MEM
mem_base: eax
size: 4
-

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 the operands for the ones below please.

@ricardojrdez ricardojrdez Nov 25, 2026 •

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.

All test cases with instructions now verify the operands, except for emms which takes no operands (passing an empty operand list makes cstest skip the operand check anyway).

- 0f 1c 08 (32): 0F 1C /1 is a reserved hint NOP and now decodes as nop
  dword ptr [eax] instead of being rejected.
- 66 0f 1c 00 (16): CLDEMOTE takes no 66 prefix, and in 16-bit mode the
  66 prefix selects a 32-bit operand, so the hint NOP operand is now
  dword instead of word.
- f3 0f 40 00 (16): the F3 prefix no longer changes the operand size of
  CMOVO, which is word again, the 16-bit default.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants