Skip to content

Commit

Permalink
encode: Add alt names for C_EX/C_SEP
Browse files Browse the repository at this point in the history
The fadec-specific names are non-standard and as the operand size is
included in the encode mnemonic anyways, also support the standard name.
  • Loading branch information
aengelke committed Jul 2, 2023
1 parent 3b93768 commit 4d88309
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions encode-test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ TEST("\x67\x66\x0f\xf7\xc1", SSE_MASKMOVDQUrr, FE_ADDR32, FE_XMM0, FE_XMM1);
TEST("\x0f\xae\xe8", LFENCE, 0);
TEST("\x0f\xae\xf0", MFENCE, 0);
TEST("\x0f\xae\xf8", SFENCE, 0);
TEST("\x66\x98", C_EX16, 0);
TEST("\x66\x98", CBW, 0);
TEST("\x98", C_EX32, 0);
TEST("\x98", CWDE, 0);
TEST("\x48\x98", C_EX64, 0);
TEST("\x48\x98", CDQE, 0);
TEST("\x66\x99", C_SEP16, 0);
TEST("\x66\x99", CWD, 0);
TEST("\x99", C_SEP32, 0);
TEST("\x99", CDQ, 0);
TEST("\x48\x99", C_SEP64, 0);
TEST("\x48\x99", CQO, 0);

// Test FD/TD encodings
TEST("\xa0\x00\x00\x00\x00\x00\x00\x00\x00", MOV8ra, 0, FE_AX, 0);
Expand Down
6 changes: 6 additions & 0 deletions parseinstrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,12 @@ def encode_mnems(entries):
if separate_opsize:
name += f"{op.abssize(opsize//8, vecsize//8)*8}"
mnemonics[name, opsize, ots].append((spec_opcode, desc))
altname = {
"C_EX16": "CBW", "C_EX32": "CWDE", "C_EX64": "CDQE",
"C_SEP16": "CWD", "C_SEP32": "CDQ", "C_SEP64": "CQO",
}.get(name)
if altname:
mnemonics[altname, opsize, ots].append((spec_opcode, desc))

for (mnem, opsize, ots), variants in mnemonics.items():
dedup = OrderedDict()
Expand Down

0 comments on commit 4d88309

Please sign in to comment.