From 3761dfe72e09e366c7f60b2f016af8e2c57c720c Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Mon, 18 Apr 2011 05:27:23 +0000 Subject: [PATCH] Added the "test" and "ud2" instructions --- src/arch/i386.ins | 34 ++++++++++++++++++++++++++++++++++ test/i386.S | 22 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/arch/i386.ins b/src/arch/i386.ins index 5b49644..b1c260b 100644 --- a/src/arch/i386.ins +++ b/src/arch/i386.ins @@ -420,6 +420,40 @@ { "fwait", 0x9b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE }, /* NOP 0x90 1 */ { "nop", 0x90, OP1F, AOT_NONE, AOT_NONE, AOT_NONE }, +/* TEST 0xa8 ib 1 al imm8 */ +{ "test", 0xa8, OP1F, OP_al, OP_S8, AOT_NONE }, +/* TEST 0xa9 iW 1 AX immW */ +{ "test", 0xa9, OP1F, OP_AX, OP_SW, AOT_NONE }, +/* TEST 0xf6 /0 ib 1 r/m8 imm8 */ +{ "testb", 0xf6, OP1F, OP_RM8_D0+0,OP_S8, AOT_NONE }, +{ "testb", 0xf6, OP1F, OP_RM8_D8+0,OP_S8, AOT_NONE }, +{ "testb", 0xf6, OP1F, OP_RM8_DW+0,OP_S8, AOT_NONE }, +{ "test", 0xf6, OP1F, OP_RM8_R8+0,OP_S8, AOT_NONE }, +/* TEST 0xf7 /0 iW 1 r/mW immW */ +{ "test", 0xf7, OP1F, OP_RMW_D0+0,OP_SW, AOT_NONE }, +{ "test", 0xf7, OP1F, OP_RMW_D8+0,OP_SW, AOT_NONE }, +{ "test", 0xf7, OP1F, OP_RMW_DW+0,OP_SW, AOT_NONE }, +{ "test", 0xf7, OP1F, OP_RMW_RW+0,OP_SW, AOT_NONE }, +/* TEST 0x84 1 r/m8 r8 */ +#if 1 /* FIXME doesn't work */ +{ "testb", 0x84, OP1F, OP_RM8_D0, OP_R8, AOT_NONE }, +{ "testb", 0x84, OP1F, OP_RM8_D8, OP_R8, AOT_NONE }, +{ "testb", 0x84, OP1F, OP_RM8_DW, OP_R8, AOT_NONE }, +{ "test", 0x84, OP1F, OP_RM8_R8, OP_R8, AOT_NONE }, +#endif +/* TEST 0x85 1 r/mW rW */ +#if 1 /* FIXME doesn't work */ +{ "test", 0x85, OP1F, OP_RMW_D0, OP_RW, AOT_NONE }, +{ "test", 0x85, OP1F, OP_RMW_D8, OP_RW, AOT_NONE }, +{ "test", 0x85, OP1F, OP_RMW_DW, OP_RW, AOT_NONE }, +{ "test", 0x85, OP1F, OP_RMW_RW, OP_RW, AOT_NONE }, +#endif +/* UD2 0x0f0b 2 */ +{ "ud2", 0x0f0b, OP2F, AOT_NONE, AOT_NONE, AOT_NONE }, +/* VERR 0x0f00 /4 2 r/m16 */ +/* FIXME implement */ +/* VERW 0x0f00 /5 2 r/m16 */ +/* FIXME implement */ /* WAIT 0x9b 1 */ { "wait", 0x9b, OP1F, AOT_NONE, AOT_NONE, AOT_NONE }, /* WBINVD 0x0f09 2 */ diff --git a/test/i386.S b/test/i386.S index 4d870c1..015f55f 100644 --- a/test/i386.S +++ b/test/i386.S @@ -146,6 +146,28 @@ fnclex fwait nop /* 90 */ + /* TEST */ + test %al, $0xaa + test %eax, $0xccddeeff + testb [%ecx], $0x04 + testb [%ecx + $0x12], $0x04 + testb [%ecx + $0x2212], $0x04 + test %bl, $0x04 + test [%ecx], $0x04002000 + test [%ecx + $0x22], $0x04002000 + test [%ecx + $0x2221], $0x04002000 + test %ebx, $0x04002000 +#if 0 /* FIXME doesn't work */ + testb [%ecx], %dh + testb [%ecx + $0x12], %ch + testb [%ecx + $0x2212], %dh + test %bl, %bh + test [%ecx], %eax + test [%ecx + $0x22], %ecx + test [%ecx + $0x2221], %edx +#endif + test %ebx, %ebx /* 85 c3 */ + ud2 wait wbinvd wrmsr