From 1de12a1f82b628bd220bf618034db8c274e95f76 Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Tue, 13 Aug 2024 21:30:03 +0300 Subject: [PATCH] final steps to the lookup table generator --- genc.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/genc.py b/genc.py index 1ed6a9c..44c62c5 100644 --- a/genc.py +++ b/genc.py @@ -42,15 +42,8 @@ class Instruction: def has_opreg(self): return False - def does_modrm(self): - if self.has_modrm(): - if self.has_digit(): - return self.modrm or self.digit is not None - else: return self.modrm is not None - else: return False - def __str__(self): - return f"<{self.get_type()}> {self.mnemonic} bytes {self.bytes} does_modrm {self.does_modrm()}" + return f"<{self.get_type()}> {self.mnemonic} bytes {self.bytes} rex {self.has_rex()} digit {self.has_digit()} modrm {self.has_modrm()} imm {self.has_imm()} value {self.has_value()} opreg {self.has_opreg()}" class InstructionCommon: REX_REGEX = re.compile("^REX\\.(.)") @@ -98,7 +91,7 @@ class StandardInstruction(Instruction): return self.digit is not None def has_modrm(self): - return self.modrm + return self.modrm or (self.digit is not None) def has_imm(self): return self.imm is not None @@ -108,9 +101,6 @@ class StandardInstruction(Instruction): def has_opreg(self): return self.opreg is not None - - def __str__(self): - return f"{super().__str__()} rex {self.rex} digit {self.digit} modrm {self.modrm} imm {self.imm} value {self.value} opreg {self.opreg}" class VEXInstruction(Instruction): def __init__(self, ins): @@ -157,9 +147,6 @@ class VEXInstruction(Instruction): def has_imm(self): return self.imm is not None - - def __str__(self): - return f"{super().__str__()} l {self.l} lig {self.lig} w {self.w} wig {self.wig}" class EVEXInstruction(Instruction): def __init__(self, ins): @@ -208,9 +195,6 @@ class EVEXInstruction(Instruction): def has_imm(self): return self.imm is not None - def __str__(self): - return f"{super().__str__()} l {self.l} lig {self.lig} w {self.w} wig {self.wig}" - def parse_instruction(ins): opc = ins.find("opc").text if "EVEX" in opc: return EVEXInstruction(ins)