Add tests for non-handled instruction format in simple x86/x64

This commit is contained in:
hakril
2024-06-27 14:03:39 +02:00
parent 7475c8893e
commit 006dce7054
2 changed files with 18 additions and 0 deletions
+12
View File
@@ -222,6 +222,7 @@ def test_assembler():
CheckInstr(Push)('RAX')
CheckInstr(Push, must_fail=True)('EAX')
assert len(Push("RAX").get_code()) == 1
CheckInstr(Push)('R15')
CheckInstr(Push)(0x42)
@@ -234,7 +235,9 @@ def test_assembler():
assert len(Pop("RAX").get_code()) == 1
CheckInstr(Call, must_fail=True)('EAX')
CheckInstr(Call)('RAX')
CheckInstr(Call)('R14')
CheckInstr(Call)(mem('[RAX + RCX * 8]'))
CheckInstr(Cpuid)()
CheckInstr(Xchg)('RAX', 'RSP')
@@ -296,6 +299,15 @@ def test_assembler():
CheckInstr(Add, must_fail=True)('RAX', 0xffffffff)
CheckInstr(Jmp, must_fail=True)('EAX')
CheckInstr(Jmp)('RAX')
CheckInstr(Jmp)('R12')
CheckInstr(Jmp)(mem('[RAX]'))
CheckInstr(Jmp)(mem('[RAX + 2]'))
CheckInstr(Jmp)(mem('[0x12345678]'))
CheckInstr(Jmp)(mem('[R15 + 0x12345678]'))
# Test some prefix / REP
assert (x64.Rep + x64.Nop()).get_code() == b"\xf3\x90"
assert (x64.GSPrefix + x64.Nop()).get_code() == b"\x65\x90"
+6
View File
@@ -230,6 +230,12 @@ def test_assembler():
CheckInstr(x86.Test, immediat_accepted=-1)('EAX', 0xffffffff)
CheckInstr(x86.Test)('ECX', 0x42)
CheckInstr(Jmp)('EAX')
CheckInstr(Jmp)('EDX')
CheckInstr(Jmp)('EDI')
CheckInstr(Jmp)(mem('[EAX]'))
CheckInstr(Jmp)(mem('[EAX + 2]'))
CheckInstr(Jmp)(mem('[0x12345678]'))
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()