old legacy disasm: omit printing rep prefix if no repeatable opcode

This commit is contained in:
Stanislav Shwartsman 2017-12-28 20:52:46 +00:00
parent 9659641cbf
commit 9abd8ba8fa
3 changed files with 85 additions and 84 deletions

View File

@ -92,7 +92,7 @@ x86_insn disassembler::decode(bx_bool is_32, bx_bool is_64, bx_address cs_base,
#define SSE_PREFIX_66 1
#define SSE_PREFIX_F3 2
#define SSE_PREFIX_F2 3 /* only one SSE prefix could be used */
unsigned sse_prefix = SSE_PREFIX_NONE, sse_opcode = 0;
unsigned sse_prefix = SSE_PREFIX_NONE, rep_opcode = 0;
unsigned rex_prefix = 0, prefixes = 0;
for(;;)
@ -264,7 +264,6 @@ x86_insn disassembler::decode(bx_bool is_32, bx_bool is_64, bx_address cs_base,
case _GRPSSE66:
/* SSE opcode group with only prefix 0x66 allowed */
sse_opcode = 1;
if (sse_prefix != SSE_PREFIX_66)
entry = &(BxDisasmGroupSSE_ERR[sse_prefix]);
attr = 0;
@ -272,7 +271,6 @@ x86_insn disassembler::decode(bx_bool is_32, bx_bool is_64, bx_address cs_base,
case _GRPSSEF2:
/* SSE opcode group with only prefix 0xF2 allowed */
sse_opcode = 1;
if (sse_prefix != SSE_PREFIX_F2)
entry = &(BxDisasmGroupSSE_ERR[sse_prefix]);
attr = 0;
@ -280,29 +278,30 @@ x86_insn disassembler::decode(bx_bool is_32, bx_bool is_64, bx_address cs_base,
case _GRPSSEF3:
/* SSE opcode group with only prefix 0xF3 allowed */
sse_opcode = 1;
if (sse_prefix != SSE_PREFIX_F3)
entry = &(BxDisasmGroupSSE_ERR[sse_prefix]);
attr = 0;
continue;
case _GRPREP:
rep_opcode = 1;
attr = 0;
continue;
case _GRPSSENONE:
/* SSE opcode group with no prefix only allowed */
sse_opcode = 1;
if (sse_prefix != SSE_PREFIX_NONE)
entry = &(BxDisasmGroupSSE_ERR[sse_prefix]);
attr = 0;
continue;
case _GRPSSE:
sse_opcode = 1;
/* For SSE opcodes, look into another 4 entries table
with the opcode prefixes (NONE, 0x66, 0xF2, 0xF3) */
entry = &(OPCODE_TABLE(entry)[sse_prefix]);
break;
case _GRPSSE2:
sse_opcode = 1;
/* For SSE opcodes, look into another 2 entries table
with the opcode prefixes (NONE, 0x66)
SSE prefixes 0xF2 and 0xF3 are not allowed */
@ -374,7 +373,7 @@ x86_insn disassembler::decode(bx_bool is_32, bx_bool is_64, bx_address cs_base,
continue;
if (prefix_byte == 0xF3 || prefix_byte == 0xF2) {
if (! sse_opcode) {
if (rep_opcode) {
const BxDisasmOpcodeTable_t *prefix = &(opcode_table[prefix_byte]);
dis_sprintf("%s ", OPCODE(prefix)->IntelOpcode);
}

View File

@ -33,11 +33,12 @@
#define _GRPSSEF3 8
#define _GRPSSENONE 9
#define _GRPSSE2 10
#define _GRPRM 11
#define _GRP3BOP 12
#define _GRP64B 13
#define _GRPVEXW 14
#define _GRPVEXL 15
#define _GRPREP 11
#define _GRPRM 12
#define _GRP3BOP 13
#define _GRP64B 14
#define _GRPVEXW 15
#define _GRPVEXL 16
/* ************************************************************************ */
#define GRPSSE(n) _GRPSSE, BxDisasmGroupSSE_##n
@ -60,6 +61,7 @@
#define GRPSSEF2(n) _GRPSSEF2, &n
#define GRPSSEF3(n) _GRPSSEF3, &n
#define GRPSSENONE(n) _GRPSSENONE, &n
#define GRPREP(n) _GRPREP, &n
/* ************************************************************************ */
#define Apw &disassembler::Apw

View File

@ -795,10 +795,10 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes16[256*2] = {
/* 69 */ { 0, &Ia_imulw_Gw_Ew_Iw },
/* 6A */ { 0, &Ia_pushw_sIb },
/* 6B */ { 0, &Ia_imulw_Gw_Ew_sIb },
/* 6C */ { 0, &Ia_insb_Yb_DX },
/* 6D */ { 0, &Ia_insw_Yw_DX },
/* 6E */ { 0, &Ia_outsb_DX_Xb },
/* 6F */ { 0, &Ia_outsw_DX_Xw },
/* 6C */ { GRPREP(Ia_insb_Yb_DX) },
/* 6D */ { GRPREP(Ia_insw_Yw_DX) },
/* 6E */ { GRPREP(Ia_outsb_DX_Xb) },
/* 6F */ { GRPREP(Ia_outsw_DX_Xw) },
/* 70 */ { 0, &Ia_jo_Jb },
/* 71 */ { 0, &Ia_jno_Jb },
/* 72 */ { 0, &Ia_jb_Jb },
@ -851,18 +851,18 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes16[256*2] = {
/* A1 */ { 0, &Ia_movw_AX_Ow },
/* A0 */ { 0, &Ia_movb_Ob_AL },
/* A1 */ { 0, &Ia_movw_Ow_AX },
/* A4 */ { 0, &Ia_movsb_Yb_Xb },
/* A5 */ { 0, &Ia_movsw_Yw_Xw },
/* A6 */ { 0, &Ia_cmpsb_Xb_Yb },
/* A7 */ { 0, &Ia_cmpsw_Xw_Yw },
/* A4 */ { GRPREP(Ia_movsb_Yb_Xb) },
/* A5 */ { GRPREP(Ia_movsw_Yw_Xw) },
/* A6 */ { GRPREP(Ia_cmpsb_Xb_Yb) },
/* A7 */ { GRPREP(Ia_cmpsw_Xw_Yw) },
/* A8 */ { 0, &Ia_testb_AL_Ib },
/* A9 */ { 0, &Ia_testw_AX_Iw },
/* AA */ { 0, &Ia_stosb_Yb_AL },
/* AB */ { 0, &Ia_stosw_Yw_AX },
/* AC */ { 0, &Ia_lodsb_AL_Xb },
/* AD */ { 0, &Ia_lodsw_AX_Xw },
/* AE */ { 0, &Ia_scasb_AL_Yb },
/* AF */ { 0, &Ia_scasw_AX_Yw },
/* AA */ { GRPREP(Ia_stosb_Yb_AL) },
/* AB */ { GRPREP(Ia_stosw_Yw_AX) },
/* AC */ { GRPREP(Ia_lodsb_AL_Xb) },
/* AD */ { GRPREP(Ia_lodsw_AX_Xw) },
/* AE */ { GRPREP(Ia_scasb_AL_Yb) },
/* AF */ { GRPREP(Ia_scasw_AX_Yw) },
/* B0 */ { 0, &Ia_movb_R8_Ib },
/* B1 */ { 0, &Ia_movb_R8_Ib },
/* B2 */ { 0, &Ia_movb_R8_Ib },
@ -1313,13 +1313,13 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes32[256*2] = {
/* 66 */ { 0, &Ia_prefix_osize }, // OSIZE:
/* 67 */ { 0, &Ia_prefix_asize }, // ASIZE:
/* 68 */ { 0, &Ia_pushl_Id },
/* 69 */ { 0, &Ia_imull_Gd_Ed_Id },
/* 69 */ { 0, &Ia_imull_Gd_Ed_Id },
/* 6A */ { 0, &Ia_pushl_sIb },
/* 6B */ { 0, &Ia_imull_Gd_Ed_sIb },
/* 6C */ { 0, &Ia_insb_Yb_DX },
/* 6D */ { 0, &Ia_insl_Yd_DX },
/* 6E */ { 0, &Ia_outsb_DX_Xb },
/* 6F */ { 0, &Ia_outsl_DX_Xd },
/* 6C */ { GRPREP(Ia_insb_Yb_DX) },
/* 6D */ { GRPREP(Ia_insl_Yd_DX) },
/* 6E */ { GRPREP(Ia_outsb_DX_Xb) },
/* 6F */ { GRPREP(Ia_outsl_DX_Xd) },
/* 70 */ { 0, &Ia_jo_Jb },
/* 71 */ { 0, &Ia_jno_Jb },
/* 72 */ { 0, &Ia_jb_Jb },
@ -1372,18 +1372,18 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes32[256*2] = {
/* A1 */ { 0, &Ia_movl_EAX_Od },
/* A0 */ { 0, &Ia_movb_Ob_AL },
/* A1 */ { 0, &Ia_movl_Od_EAX },
/* A4 */ { 0, &Ia_movsb_Yb_Xb },
/* A5 */ { 0, &Ia_movsl_Yd_Xd },
/* A6 */ { 0, &Ia_cmpsb_Xb_Yb },
/* A7 */ { 0, &Ia_cmpsl_Xd_Yd },
/* A4 */ { GRPREP(Ia_movsb_Yb_Xb) },
/* A5 */ { GRPREP(Ia_movsl_Yd_Xd) },
/* A6 */ { GRPREP(Ia_cmpsb_Xb_Yb) },
/* A7 */ { GRPREP(Ia_cmpsl_Xd_Yd) },
/* A8 */ { 0, &Ia_testb_AL_Ib },
/* A9 */ { 0, &Ia_testl_EAX_Id },
/* AA */ { 0, &Ia_stosb_Yb_AL },
/* AB */ { 0, &Ia_stosl_Yd_EAX },
/* AC */ { 0, &Ia_lodsb_AL_Xb },
/* AD */ { 0, &Ia_lodsl_EAX_Xd },
/* AE */ { 0, &Ia_scasb_AL_Yb },
/* AF */ { 0, &Ia_scasl_EAX_Yd },
/* AA */ { GRPREP(Ia_stosb_Yb_AL) },
/* AB */ { GRPREP(Ia_stosl_Yd_EAX) },
/* AC */ { GRPREP(Ia_lodsb_AL_Xb) },
/* AD */ { GRPREP(Ia_lodsl_EAX_Xd) },
/* AE */ { GRPREP(Ia_scasb_AL_Yb) },
/* AF */ { GRPREP(Ia_scasl_EAX_Yd) },
/* B0 */ { 0, &Ia_movb_R8_Ib },
/* B1 */ { 0, &Ia_movb_R8_Ib },
/* B2 */ { 0, &Ia_movb_R8_Ib },
@ -1837,10 +1837,10 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes64w[256*2] = {
/* 69 */ { 0, &Ia_imulw_Gw_Ew_Iw },
/* 6A */ { 0, &Ia_pushw_sIb },
/* 6B */ { 0, &Ia_imulw_Gw_Ew_sIb },
/* 6C */ { 0, &Ia_insb_Yb_DX },
/* 6D */ { 0, &Ia_insw_Yw_DX },
/* 6E */ { 0, &Ia_outsb_DX_Xb },
/* 6F */ { 0, &Ia_outsw_DX_Xw },
/* 6C */ { GRPREP(Ia_insb_Yb_DX) },
/* 6D */ { GRPREP(Ia_insw_Yw_DX) },
/* 6E */ { GRPREP(Ia_outsb_DX_Xb) },
/* 6F */ { GRPREP(Ia_outsw_DX_Xw) },
/* 70 */ { 0, &Ia_jo_Jb },
/* 71 */ { 0, &Ia_jno_Jb },
/* 72 */ { 0, &Ia_jb_Jb },
@ -1893,18 +1893,18 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes64w[256*2] = {
/* A1 */ { 0, &Ia_movw_AX_Ow },
/* A0 */ { 0, &Ia_movb_Ob_AL },
/* A1 */ { 0, &Ia_movw_Ow_AX },
/* A4 */ { 0, &Ia_movsb_Yb_Xb },
/* A5 */ { 0, &Ia_movsw_Yw_Xw },
/* A6 */ { 0, &Ia_cmpsb_Xb_Yb },
/* A7 */ { 0, &Ia_cmpsw_Xw_Yw },
/* A4 */ { GRPREP(Ia_movsb_Yb_Xb) },
/* A5 */ { GRPREP(Ia_movsw_Yw_Xw) },
/* A6 */ { GRPREP(Ia_cmpsb_Xb_Yb) },
/* A7 */ { GRPREP(Ia_cmpsw_Xw_Yw) },
/* A8 */ { 0, &Ia_testb_AL_Ib },
/* A9 */ { 0, &Ia_testw_AX_Iw },
/* AA */ { 0, &Ia_stosb_Yb_AL },
/* AB */ { 0, &Ia_stosw_Yw_AX },
/* AC */ { 0, &Ia_lodsb_AL_Xb },
/* AD */ { 0, &Ia_lodsw_AX_Xw },
/* AE */ { 0, &Ia_scasb_AL_Yb },
/* AF */ { 0, &Ia_scasw_AX_Yw },
/* AA */ { GRPREP(Ia_stosb_Yb_AL) },
/* AB */ { GRPREP(Ia_stosw_Yw_AX) },
/* AC */ { GRPREP(Ia_lodsb_AL_Xb) },
/* AD */ { GRPREP(Ia_lodsw_AX_Xw) },
/* AE */ { GRPREP(Ia_scasb_AL_Yb) },
/* AF */ { GRPREP(Ia_scasw_AX_Yw) },
/* B0 */ { 0, &Ia_movb_R8_Ib },
/* B1 */ { 0, &Ia_movb_R8_Ib },
/* B2 */ { 0, &Ia_movb_R8_Ib },
@ -2355,10 +2355,10 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes64d[256*2] = {
/* 69 */ { 0, &Ia_imull_Gd_Ed_Id },
/* 6A */ { 0, &Ia_pushq_sIb },
/* 6B */ { 0, &Ia_imull_Gd_Ed_sIb },
/* 6C */ { 0, &Ia_insb_Yb_DX },
/* 6D */ { 0, &Ia_insl_Yd_DX },
/* 6E */ { 0, &Ia_outsb_DX_Xb },
/* 6F */ { 0, &Ia_outsl_DX_Xd },
/* 6C */ { GRPREP(Ia_insb_Yb_DX) },
/* 6D */ { GRPREP(Ia_insl_Yd_DX) },
/* 6E */ { GRPREP(Ia_outsb_DX_Xb) },
/* 6F */ { GRPREP(Ia_outsl_DX_Xd) },
/* 70 */ { 0, &Ia_jo_Jb },
/* 71 */ { 0, &Ia_jno_Jb },
/* 72 */ { 0, &Ia_jb_Jb },
@ -2411,18 +2411,18 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes64d[256*2] = {
/* A1 */ { 0, &Ia_movl_EAX_Od },
/* A0 */ { 0, &Ia_movb_Ob_AL },
/* A1 */ { 0, &Ia_movl_Od_EAX },
/* A4 */ { 0, &Ia_movsb_Yb_Xb },
/* A5 */ { 0, &Ia_movsl_Yd_Xd },
/* A6 */ { 0, &Ia_cmpsb_Xb_Yb },
/* A7 */ { 0, &Ia_cmpsl_Xd_Yd },
/* A4 */ { GRPREP(Ia_movsb_Yb_Xb) },
/* A5 */ { GRPREP(Ia_movsl_Yd_Xd) },
/* A6 */ { GRPREP(Ia_cmpsb_Xb_Yb) },
/* A7 */ { GRPREP(Ia_cmpsl_Xd_Yd) },
/* A8 */ { 0, &Ia_testb_AL_Ib },
/* A9 */ { 0, &Ia_testl_EAX_Id },
/* AA */ { 0, &Ia_stosb_Yb_AL },
/* AB */ { 0, &Ia_stosl_Yd_EAX },
/* AC */ { 0, &Ia_lodsb_AL_Xb },
/* AD */ { 0, &Ia_lodsl_EAX_Xd },
/* AE */ { 0, &Ia_scasb_AL_Yb },
/* AF */ { 0, &Ia_scasl_EAX_Yd },
/* AA */ { GRPREP(Ia_stosb_Yb_AL) },
/* AB */ { GRPREP(Ia_stosl_Yd_EAX) },
/* AC */ { GRPREP(Ia_lodsb_AL_Xb) },
/* AD */ { GRPREP(Ia_lodsl_EAX_Xd) },
/* AE */ { GRPREP(Ia_scasb_AL_Yb) },
/* AF */ { GRPREP(Ia_scasl_EAX_Yd) },
/* B0 */ { 0, &Ia_movb_R8_Ib },
/* B1 */ { 0, &Ia_movb_R8_Ib },
/* B2 */ { 0, &Ia_movb_R8_Ib },
@ -2873,10 +2873,10 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes64q[256*2] = {
/* 69 */ { 0, &Ia_imulq_Gq_Eq_sId },
/* 6A */ { 0, &Ia_pushq_sIb },
/* 6B */ { 0, &Ia_imulq_Gq_Eq_sIb },
/* 6C */ { 0, &Ia_insb_Yb_DX },
/* 6D */ { 0, &Ia_insl_Yd_DX },
/* 6E */ { 0, &Ia_outsb_DX_Xb },
/* 6F */ { 0, &Ia_outsl_DX_Xd },
/* 6C */ { GRPREP(Ia_insb_Yb_DX) },
/* 6D */ { GRPREP(Ia_insl_Yd_DX) },
/* 6E */ { GRPREP(Ia_outsb_DX_Xb) },
/* 6F */ { GRPREP(Ia_outsl_DX_Xd) },
/* 70 */ { 0, &Ia_jo_Jb },
/* 71 */ { 0, &Ia_jno_Jb },
/* 72 */ { 0, &Ia_jb_Jb },
@ -2929,18 +2929,18 @@ static BxDisasmOpcodeTable_t BxDisasmOpcodes64q[256*2] = {
/* A1 */ { 0, &Ia_movq_RAX_Oq },
/* A0 */ { 0, &Ia_movb_Ob_AL },
/* A1 */ { 0, &Ia_movq_Oq_RAX },
/* A4 */ { 0, &Ia_movsb_Yb_Xb },
/* A5 */ { 0, &Ia_movsq_Yq_Xq },
/* A6 */ { 0, &Ia_cmpsb_Xb_Yb },
/* A7 */ { 0, &Ia_cmpsq_Xq_Yq },
/* A4 */ { GRPREP(Ia_movsb_Yb_Xb) },
/* A5 */ { GRPREP(Ia_movsq_Yq_Xq) },
/* A6 */ { GRPREP(Ia_cmpsb_Xb_Yb) },
/* A7 */ { GRPREP(Ia_cmpsq_Xq_Yq) },
/* A8 */ { 0, &Ia_testb_AL_Ib },
/* A9 */ { 0, &Ia_testq_RAX_sId },
/* AA */ { 0, &Ia_stosb_Yb_AL },
/* AB */ { 0, &Ia_stosq_Yq_RAX },
/* AC */ { 0, &Ia_lodsb_AL_Xb },
/* AD */ { 0, &Ia_lodsq_RAX_Xq },
/* AE */ { 0, &Ia_scasb_AL_Yb },
/* AF */ { 0, &Ia_scasq_RAX_Yq },
/* AA */ { GRPREP(Ia_stosb_Yb_AL) },
/* AB */ { GRPREP(Ia_stosq_Yq_RAX) },
/* AC */ { GRPREP(Ia_lodsb_AL_Xb) },
/* AD */ { GRPREP(Ia_lodsq_RAX_Xq) },
/* AE */ { GRPREP(Ia_scasb_AL_Yb) },
/* AF */ { GRPREP(Ia_scasq_RAX_Yq) },
/* B0 */ { 0, &Ia_movb_R8_Ib },
/* B1 */ { 0, &Ia_movb_R8_Ib },
/* B2 */ { 0, &Ia_movb_R8_Ib },