Skip to content

x86: honor mandatory 66 prefix in 16-bit mode - #3184

Open
ricardojrdez wants to merge 1 commit into
capstone-engine:nextfrom
reverseame:x86-16bit-mandatory-66
Open

ricardojrdez wants to merge 1 commit into
capstone-engine:nextfrom
reverseame:x86-16bit-mandatory-66

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

  • 66 0f 2f 00 (16): the 66 prefix is now taken as the mandatory prefix
    in 16-bit mode when it selects another instruction, so this decodes as
    COMISD with a qword operand instead of COMISS.
  • 66 0f ef c0 (16): for the same reason, PXOR now uses the SSE2 xmm
    registers instead of the MMX ones.

Test plan

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

@ricardojrdez

Copy link
Copy Markdown
Contributor Author

Note that #3185 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 94.44444% 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/X86DisassemblerDecoder.c 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3184   +/-   ##
=======================================
  Coverage        ?   61.88%           
=======================================
  Files           ?      243           
  Lines           ?    56934           
  Branches        ?    10128           
=======================================
  Hits            ?    35233           
  Misses          ?    16498           
  Partials        ?     5203           

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

@ricardojrdez
ricardojrdez force-pushed the x86-16bit-mandatory-66 branch from db4054f to 9a40e3d Compare November 25, 2026 14:58
insns: []
-
input:
name: "x86 (16-bit): 66 is the mandatory prefix of COMISD"

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.

Also add a negative test (missing 66 prefix).

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.

Added the negative test case (0f 2f 00 -> comiss, dword operand).

Note that this case also passes without the fix, as its purpose is to act as a regression check ensuring that the fix doesn't mistakenly decode 0f 2f as COMISD when the 0x66 prefix is missing.

- 66 0f 2f 00 (16): the 66 prefix is now taken as the mandatory prefix
  in 16-bit mode when it selects another instruction, so this decodes as
  COMISD with a qword operand instead of COMISS.
- 66 0f ef c0 (16): for the same reason, PXOR now uses the SSE2 xmm
  registers instead of the MMX ones.

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