Compare commits

..

2 Commits

Author SHA1 Message Date
hakril 8d5bb5c032 Add simplex_86 ljmp with standard parameter format handling for ptr16:32 2025-06-30 15:48:59 +02:00
hakril e4ca049004 Merge pull request #80 from hakril/updates
Updates
2025-05-15 01:28:06 -07:00
2 changed files with 18 additions and 0 deletions
+4
View File
@@ -236,6 +236,10 @@ def test_assembler():
CheckInstr(Jmp)(mem('[EAX]')) CheckInstr(Jmp)(mem('[EAX]'))
CheckInstr(Jmp)(mem('[EAX + 2]')) CheckInstr(Jmp)(mem('[EAX + 2]'))
CheckInstr(Jmp)(mem('[0x12345678]')) CheckInstr(Jmp)(mem('[0x12345678]'))
# Ljmp testing
CheckInstr(Ljmp)(0x33, 0x12345678)
CheckInstr(Ljmp, expected_result="ljmp 0x23:0x11223344")("0x23:0x11223344")
assert Ljmp(0x33, 0x12345678).get_code() == Ljmp("0x33:0x12345678").get_code()
assert x86.Test(mem('[ECX + 0x100]'), 'ECX').get_code() == x86.Test('ECX', mem('[ECX + 0x100]')).get_code() assert x86.Test(mem('[ECX + 0x100]'), 'ECX').get_code() == x86.Test('ECX', mem('[ECX + 0x100]')).get_code()
assert Xchg('EAX', 'ECX').get_code() == Xchg('ECX', 'EAX').get_code() assert Xchg('EAX', 'ECX').get_code() == Xchg('ECX', 'EAX').get_code()
+14
View File
@@ -400,6 +400,16 @@ class Imm32(object):
class SegmentSelectorAbsoluteAddr(object): class SegmentSelectorAbsoluteAddr(object):
def accept_arg(self, args, instr_state): def accept_arg(self, args, instr_state):
# Special case ptr 16:32
if isinstance(args[0], str) and args[0].count(":") == 1:
imm16, imm32 = [int(x, 0) for x in args[0].split(":")]
sizess, datass = UImm16().accept_arg([imm16], instr_state)
sizeabs, dataabs = Imm32().accept_arg([imm32], instr_state)
if sizess is None or sizeabs is None:
return None, None
# We only consumed 1 args as it was the same string
return (1, dataabs + datass)
sizess, datass = UImm16().accept_arg(args, instr_state) sizess, datass = UImm16().accept_arg(args, instr_state)
if sizess is None: if sizess is None:
return None, None return None, None
@@ -711,6 +721,10 @@ class Jmp(JmpType):
(RawBits.from_int(8, 0xff), Slash(4)), (RawBits.from_int(8, 0xff), Slash(4)),
(RawBits.from_int(8, 0xea), SegmentSelectorAbsoluteAddr())] (RawBits.from_int(8, 0xea), SegmentSelectorAbsoluteAddr())]
# Allow a second mnemonic for the longjump
class Ljmp(JmpType):
encoding = [(RawBits.from_int(8, 0xea), SegmentSelectorAbsoluteAddr())]
class Jz(JmpType): class Jz(JmpType):
encoding = [(RawBits.from_int(8, 0x74), JmpImm8(2)), encoding = [(RawBits.from_int(8, 0x74), JmpImm8(2)),