From 4d883094693059972d5533fbb06d0e5955ed3182 Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Sun, 2 Jul 2023 16:05:14 +0200 Subject: [PATCH] encode: Add alt names for C_EX/C_SEP The fadec-specific names are non-standard and as the operand size is included in the encode mnemonic anyways, also support the standard name. --- encode-test.inc | 12 ++++++++++++ parseinstrs.py | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/encode-test.inc b/encode-test.inc index e01e8e2..661ee28 100644 --- a/encode-test.inc +++ b/encode-test.inc @@ -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); diff --git a/parseinstrs.py b/parseinstrs.py index 3409d38..af1ad40 100644 --- a/parseinstrs.py +++ b/parseinstrs.py @@ -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()