From 6abc971576b4430c4faf1087b1230a6f8d6f08c1 Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Mon, 24 Apr 2023 08:55:56 +0200 Subject: [PATCH] decode: Move instr-width to legacy path Very few instructions set use instrwidth, so move this check as well to the legacy path. The only affected common instructions are RET and LEAVE. --- decode.c | 4 ++-- parseinstrs.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/decode.c b/decode.c index 3d8d825..38f2545 100644 --- a/decode.c +++ b/decode.c @@ -767,9 +767,9 @@ skip_modrm: return FD_ERR_UD; } - instr->operandsz = 0; - } else { instr->operandsz = UNLIKELY(DESC_INSTR_WIDTH(desc)) ? op_size - 1 : 0; + } else { + instr->operandsz = 0; } instr->size = off; diff --git a/parseinstrs.py b/parseinstrs.py index 4098b31..6f824c2 100644 --- a/parseinstrs.py +++ b/parseinstrs.py @@ -276,17 +276,17 @@ class InstrDesc(NamedTuple): else: # either empty or GP operand size dynsizes = [OpKind.SZ_OP] if "SZ8" in self.flags: - extraflags["opsize"] = 1 dynsizes = [] if "D64" in self.flags: extraflags["opsize"] = 2 if "F64" in self.flags: extraflags["opsize"] = 3 - extraflags["instr_width"] = "INSTR_WIDTH" in self.flags extraflags["lock"] = "LOCK" in self.flags - if "SZ8" in self.flags or mnem in ("MOVSX", "MOVZX", "XCHG_NOP", "3DNOW"): - if "SZ8" not in self.flags and "INSTR_WIDTH" in self.flags: - raise Exception("legacy instr with +w without SZ8") + if (self.flags & {"SZ8", "INSTR_WIDTH"} or + mnem in ("MOVSX", "MOVZX", "XCHG_NOP", "3DNOW")): extraflags["legacy"] = 1 + # INSTR_WIDTH defaults to zero, so only enable when SZ8 is unset + if "INSTR_WIDTH" in self.flags and "SZ8" not in self.flags: + extraflags["instr_width"] = 1 imm_byte = self.imm_size(4) == 1 extraflags["imm_control"] = flags.imm_control | imm_byte