From af9188e26716133d277fb8f508f077b15daa06ef Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Sun, 10 Jan 2021 12:02:08 +0100 Subject: [PATCH] parseinstrs: Respect mem-only/reg-only encodings --- decode.c | 3 --- parseinstrs.py | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/decode.c b/decode.c index 05f16de..7383142 100644 --- a/decode.c +++ b/decode.c @@ -358,9 +358,6 @@ prefix_end: if (mod == 3 || is_cr || is_dr) { - if (op_modrm->misc == FD_RT_MEM) - return FD_ERR_UD; - uint8_t reg_idx = rm; if (LIKELY(op_modrm->misc == FD_RT_GPL || op_modrm->misc == FD_RT_VEC)) reg_idx += prefix_rex & PREFIX_REXB ? 8 : 0; diff --git a/parseinstrs.py b/parseinstrs.py index 8f937fb..46d4545 100644 --- a/parseinstrs.py +++ b/parseinstrs.py @@ -285,8 +285,8 @@ class Opcode(NamedTuple): if self.opcext: opcode.append((EntryKind.TABLE16, [((self.opcext - 0xc0) >> 3) | 8])) opcode.append((EntryKind.TABLE8E, [self.opcext & 7])) - if self.modreg and self.modreg[0] is not None: - # TODO: support for /r and /m specifiers, currently adds ~1.9kiB size + if self.modreg: + # TODO: optimize for /r and /m specifiers to reduce size mod = {"m": [0], "r": [1<<3], "rm": [0, 1<<3]}[self.modreg[1]] reg = [self.modreg[0]] if self.modreg[0] is not None else list(range(8)) opcode.append((EntryKind.TABLE16, [x + y for x in mod for y in reg]))