now I can definitely tell if instruction has ModRM byte or no
This commit is contained in:
parent
5998950f23
commit
a681a53ff3
2 changed files with 24 additions and 8 deletions
31
genc.py
31
genc.py
|
|
@ -25,14 +25,29 @@ class Instruction:
|
||||||
value = Instruction.VALUE_REGEX.search(opc)
|
value = Instruction.VALUE_REGEX.search(opc)
|
||||||
opreg = Instruction.OPREG_REGEX.search(opc)
|
opreg = Instruction.OPREG_REGEX.search(opc)
|
||||||
|
|
||||||
print(ins.find("mnem").text)
|
self.mnemonic = ins.find("mnem").text
|
||||||
if rex: print("rex\t", rex.group(1))
|
self.bytes = bytes
|
||||||
print(bytes)
|
|
||||||
if digit: print("digit\t", digit.group(1))
|
self.rex = None
|
||||||
if modrm: print("modrm\t", modrm.group(0))
|
self.digit = None
|
||||||
if imm: print("imm\t", imm.group(1))
|
self.modrm = False
|
||||||
if value: print("value\t", value.group(1))
|
self.imm = None
|
||||||
if opreg: print("opreg\t", opreg.group(1))
|
self.value = None
|
||||||
|
self.opreg = None
|
||||||
|
|
||||||
|
if rex: self.rex = rex.group(1)
|
||||||
|
if digit: self.digit = int(digit.group(1))
|
||||||
|
if modrm: self.modrm = True
|
||||||
|
if imm: self.imm = imm.group(1)
|
||||||
|
if value: self.value = value.group(1)
|
||||||
|
if opreg: self.opreg = opreg.group(1)
|
||||||
|
|
||||||
|
self.has_modrm = self.modrm or self.digit is not None
|
||||||
|
|
||||||
|
print(self)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.mnemonic} rex {self.rex} bytes {self.bytes} has_modrm {self.has_modrm} digit {self.digit} modrm {self.modrm} imm {self.imm} value {self.value} opreg {self.opreg}"
|
||||||
|
|
||||||
class InstructionGroup:
|
class InstructionGroup:
|
||||||
def __init__(self, common):
|
def __init__(self, common):
|
||||||
|
|
|
||||||
1
plan.txt
1
plan.txt
|
|
@ -1,4 +1,5 @@
|
||||||
The Intel OpCode Syntax can tell if there is ModRM byte, as well as if registers are encoded directly in opcode (rb for example),
|
The Intel OpCode Syntax can tell if there is ModRM byte, as well as if registers are encoded directly in opcode (rb for example),
|
||||||
and can tell size of immediate (ib iw id for example). The /digit can also indiciate presense of ModRM.
|
and can tell size of immediate (ib iw id for example). The /digit can also indiciate presense of ModRM.
|
||||||
The size of displacement is also dictated by cw/cd.
|
The size of displacement is also dictated by cw/cd.
|
||||||
|
ModRM also can tell if there is SIB byte or no.
|
||||||
VEX prefixes. 0xC5 for 3-byte VEX and 0xC4 for 2-byte prefix
|
VEX prefixes. 0xC5 for 3-byte VEX and 0xC4 for 2-byte prefix
|
||||||
Loading…
Add table
Reference in a new issue