Repository navigation
insns: fix CCMP immediate template ordering and add CTEST reg, mem symmetry - #322
agourakis82 wants to merge 2 commits into
Conversation
…mmetry Fixes netwide-assembler#316. Fixes netwide-assembler#317. 1. In x86/insns.dat, CCMPscc declared the $wdq sbyte# template (opcode 83 /7) before the $bwdq imm# template (opcode 80# /7). For an instruction like: ccmpb {dfv=} [rsp], byte 10 the explicit byte immediate (BITS8) matched sbyteword16 via BYTEEXTMASK promotion in asm/assemble.c. Because [rsp] carried no explicit size, SM1-2 matched both operands to 16 bits, choosing the word template (83 /7) instead of the 8-bit template (80 /7). Placing rm8, imm8 before $wdq sbyte# (matching classic CMP ordering) ensures 8-bit comparisons assemble to 8-bit form. 2. Added symmetric $bwdq CTESTscc spec4,reg#,mem# [wrm: evex... 84# /r] with ND, matching the existing syntactic sugar of legacy TEST reg#,mem#.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Add regression fixtures covering the unsized-memory CCMP form and CTEST reg, mem syntax.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Updates APX instruction templates to fix CCMP immediate encoding selection and add symmetric CTEST register/memory syntax.
Changes:
- Prioritizes the 8-bit CCMP immediate encoding.
- Restricts wider CCMP immediate forms appropriately.
- Adds the
CTEST reg, memalias using canonical84 /r.
| File | Description |
|---|---|
x86/insns.dat |
Updates CCMP template ordering and adds CTEST operand symmetry. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Yea, much more will be interesting to add syntax sugar for CMOV/CFCMOV, as this hack requiers to change logic not only in |
|
Follow-up regression fixtures are now included in |

Fixes #316.
Fixes #317.
Summary
Fix CCMP 8-bit immediate ordering (Bug in
CCMP [mem], word imm#316):In
x86/insns.dat,CCMPsccpreviously declared the$wdq sbyte#template (opcode83 /7) before the$bwdq imm#template (opcode80# /7).For an instruction like:
the explicit byte immediate (
BITS8) matchedsbyteword16via theBYTEEXTMASKpromotion logic inasm/assemble.c. Because[rsp]carried no explicit size specifier,SM1-2matched both operands to 16 bits, incorrectly choosing the word template (83 /7) instead of the 8-bit template (80 /7).Placing
rm8, imm8ahead of$wdq sbyte#(matching the template ordering of classicCMP) ensures 8-bit comparisons assemble to the correct 8-bit opcode (80 /7).Add CTEST reg, mem symmetry (Possible syntactic sugar for
CTEST reg, memthat is missing #317):Added the symmetric template:
with
ND(No Disassembly), matching the existing syntactic sugar in legacyTEST reg#,mem#and allowing instructions like:to assemble cleanly into the canonical
84 /rencoding.