Skip to content

Commit a8de401

Browse files
committed
decode-test: Test suffixes more thoroughly
1 parent ad3c3ca commit a8de401

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

decode-test.c

+21
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ main(int argc, char** argv)
223223
TEST("\x01\x04\x25\x01\x00\x00\x00", "add dword ptr [0x1], eax");
224224
TEST3264("\x01\x04\x25\x00\x00\x00\x80", "add dword ptr [0x80000000], eax", "add dword ptr [0xffffffff80000000], eax");
225225
TEST64("\x41\x01\x04\x25\x01\x00\x00\x00", "add dword ptr [0x1], eax");
226+
TEST("\x01\x04\x25\x00\x00\x00\x00", "add dword ptr [0x0], eax");
226227
// [rip+disp32]
227228
TEST64("\x01\x05\x01\x00\x00\x00", "add dword ptr [rip+0x1], eax");
228229
TEST64("\x41\x01\x05\x01\x00\x00\x00", "add dword ptr [rip+0x1], eax");
@@ -1146,6 +1147,10 @@ main(int argc, char** argv)
11461147
TEST32("\xc5\x00", "lds eax, fword ptr [eax]");
11471148
TEST("\x0f\xb2\x00", "lss eax, fword ptr [@ax]");
11481149
TEST64("\x48\x0f\xb2\x00", "lss rax, tbyte ptr [rax]");
1150+
TEST("\x0f\xb4\x00", "lfs eax, fword ptr [@ax]");
1151+
TEST64("\x48\x0f\xb4\x00", "lfs rax, tbyte ptr [rax]");
1152+
TEST("\x0f\xb5\x00", "lgs eax, fword ptr [@ax]");
1153+
TEST64("\x48\x0f\xb5\x00", "lgs rax, tbyte ptr [rax]");
11491154
TEST("\xc5\xf2\x2a\xc0", "vcvtsi2ss xmm0, xmm1, eax");
11501155
TEST("\xc4\xe1\xf2\x2a\xc0", "vcvtsi2ss xmm0, xmm1, @ax"); // VEX.W ignored
11511156
TEST("\xf3\xc5\xf2\x2a\xc0", "UD"); // VEX+REP
@@ -1615,6 +1620,20 @@ main(int argc, char** argv)
16151620

16161621
TEST("\x0f\xae\x00", "fxsave [@ax]");
16171622
TEST64("\x48\x0f\xae\x00", "fxsave64 [rax]");
1623+
TEST("\x0f\xae\x08", "fxrstor [@ax]");
1624+
TEST64("\x48\x0f\xae\x08", "fxrstor64 [rax]");
1625+
TEST("\x0f\xae\x20", "xsave [@ax]");
1626+
TEST64("\x48\x0f\xae\x20", "xsave64 [rax]");
1627+
TEST("\x0f\xc7\x20", "xsavec [@ax]");
1628+
TEST64("\x48\x0f\xc7\x20", "xsavec64 [rax]");
1629+
TEST("\x0f\xae\x30", "xsaveopt [@ax]");
1630+
TEST64("\x48\x0f\xae\x30", "xsaveopt64 [rax]");
1631+
TEST("\x0f\xc7\x28", "xsaves [@ax]");
1632+
TEST64("\x48\x0f\xc7\x28", "xsaves64 [rax]");
1633+
TEST("\x0f\xae\x28", "xrstor [@ax]");
1634+
TEST64("\x48\x0f\xae\x28", "xrstor64 [rax]");
1635+
TEST("\x0f\xc7\x18", "xrstors [@ax]");
1636+
TEST64("\x48\x0f\xc7\x18", "xrstors64 [rax]");
16181637
TEST("\xff\xe0", "jmp @ax");
16191638
TEST3264("\x66\xff\xe0", "jmp ax", "jmp rax");
16201639
TEST64("\x48\xff\xe0", "jmp rax");
@@ -1672,6 +1691,8 @@ main(int argc, char** argv)
16721691
// TEST64("\x48\xe7\xff", "out eax, 0xff"); // TODO
16731692
TEST32("\x66\x61", "popaw");
16741693
TEST32("\x61", "popad");
1694+
TEST("\x66\x9c", "pushfw");
1695+
TEST3264("\x9c", "pushfd", "pushfq");
16751696
TEST("\x66\x9d", "popfw");
16761697
TEST3264("\x9d", "popfd", "popfq");
16771698
TEST("\x66\xcf", "iretw");

parseinstrs.py

+2
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ def verifyOpcodeDesc(opcode, desc):
392392
raise Exception(f"vexreg operand-regkind mismatch {opcode}, {desc}")
393393
if oporder[i] == "imm" and opkind.regkind not in expected_immkinds:
394394
raise Exception(f"imm operand-regkind mismatch {opcode}, {desc}")
395+
if "INSTR_WIDTH" in desc.flags and len(desc.operands) > 3:
396+
raise Exception(f"+w with four operands {opcode}, {desc}")
395397
if opcode.escape == 2 and flags.imm_control != 0:
396398
raise Exception(f"0f38 has no immediate operand {opcode}, {desc}")
397399
if opcode.escape == 3 and desc.imm_size(4) != 1:

0 commit comments

Comments
 (0)