diff --git a/arch/X86/X86ATTInstPrinter.c b/arch/X86/X86ATTInstPrinter.c index 6837d266e8..301bffca18 100644 --- a/arch/X86/X86ATTInstPrinter.c +++ b/arch/X86/X86ATTInstPrinter.c @@ -65,13 +65,49 @@ static void printopaquemem(MCInst *MI, unsigned OpNo, SStream *O) { switch(MI->csh->mode) { case CS_MODE_16: - MI->x86opsize = 2; + switch(MI->flat_insn->id) { + default: + MI->x86opsize = 2; + break; + case X86_INS_LJMP: + case X86_INS_LCALL: + case X86_INS_SGDT: + case X86_INS_SIDT: + case X86_INS_LGDT: + case X86_INS_LIDT: + MI->x86opsize = 4; + break; + } break; case CS_MODE_32: - MI->x86opsize = 4; + switch(MI->flat_insn->id) { + default: + MI->x86opsize = 4; + break; + case X86_INS_LJMP: + case X86_INS_LCALL: + case X86_INS_SGDT: + case X86_INS_SIDT: + case X86_INS_LGDT: + case X86_INS_LIDT: + MI->x86opsize = 6; + break; + } break; case CS_MODE_64: - MI->x86opsize = 8; + switch(MI->flat_insn->id) { + default: + MI->x86opsize = 8; + break; + case X86_INS_LJMP: + case X86_INS_LCALL: + case X86_INS_SGDT: + case X86_INS_SIDT: + case X86_INS_LGDT: + case X86_INS_LIDT: + MI->x86opsize = 10; + break; + } break; default: // never reach break; diff --git a/arch/X86/X86IntelInstPrinter.c b/arch/X86/X86IntelInstPrinter.c index 86dc0b3681..69e222da85 100644 --- a/arch/X86/X86IntelInstPrinter.c +++ b/arch/X86/X86IntelInstPrinter.c @@ -63,26 +63,64 @@ static void set_mem_access(MCInst *MI, bool status) static void printopaquemem(MCInst *MI, unsigned OpNo, SStream *O) { - SStream_concat0(O, "ptr "); + // FIXME: do this with autogen + switch(MI->flat_insn->id) { + default: + SStream_concat0(O, "ptr "); + break; + case X86_INS_SGDT: + case X86_INS_SIDT: + case X86_INS_LGDT: + case X86_INS_LIDT: + // do not print "ptr" + break; + } switch(MI->csh->mode) { case CS_MODE_16: - if (MI->flat_insn->id == X86_INS_LJMP || MI->flat_insn->id == X86_INS_LCALL) - MI->x86opsize = 4; - else - MI->x86opsize = 2; + switch(MI->flat_insn->id) { + default: + MI->x86opsize = 2; + break; + case X86_INS_LJMP: + case X86_INS_LCALL: + case X86_INS_SGDT: + case X86_INS_SIDT: + case X86_INS_LGDT: + case X86_INS_LIDT: + MI->x86opsize = 4; + break; + } break; case CS_MODE_32: - if (MI->flat_insn->id == X86_INS_LJMP || MI->flat_insn->id == X86_INS_LCALL) - MI->x86opsize = 6; - else - MI->x86opsize = 4; + switch(MI->flat_insn->id) { + default: + MI->x86opsize = 4; + break; + case X86_INS_LJMP: + case X86_INS_LCALL: + case X86_INS_SGDT: + case X86_INS_SIDT: + case X86_INS_LGDT: + case X86_INS_LIDT: + MI->x86opsize = 6; + break; + } break; case CS_MODE_64: - if (MI->flat_insn->id == X86_INS_LJMP || MI->flat_insn->id == X86_INS_LCALL) - MI->x86opsize = 10; - else - MI->x86opsize = 8; + switch(MI->flat_insn->id) { + default: + MI->x86opsize = 8; + break; + case X86_INS_LJMP: + case X86_INS_LCALL: + case X86_INS_SGDT: + case X86_INS_SIDT: + case X86_INS_LGDT: + case X86_INS_LIDT: + MI->x86opsize = 10; + break; + } break; default: // never reach break; diff --git a/suite/regress.py b/suite/regress.py index 196cb9a19c..c8d80f0354 100755 --- a/suite/regress.py +++ b/suite/regress.py @@ -448,16 +448,16 @@ (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x66\x67\xAE", "scasb al, byte ptr [edi]"), (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x66\x67\xAF", "scasw ax, word ptr [edi]"), - (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x0f\x01\x05\xa0\x90\x04\x08", "sgdt [rip+0x80490a0]"), + (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x0f\x01\x05\xa0\x90\x04\x08", "sgdt [rip + 0x80490a0]"), (CS_ARCH_X86, CS_MODE_32, CS_OPT_SYNTAX_INTEL, 0x9123ffe1, b"\x0f\x01\x05\xa0\x90\x04\x08", "sgdt [0x80490a0]"), (CS_ARCH_X86, CS_MODE_16, CS_OPT_SYNTAX_INTEL, 0xffe1, b"\x0f\x01\x05", "sgdt [di]"), - (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x0f\x01\x0d\xa0\x90\x04\x08", "sidt [rip+0x80490a0]"), + (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x0f\x01\x0d\xa0\x90\x04\x08", "sidt [rip + 0x80490a0]"), (CS_ARCH_X86, CS_MODE_32, CS_OPT_SYNTAX_INTEL, 0x9123ffe1, b"\x0f\x01\x0d\xa0\x90\x04\x08", "sidt [0x80490a0]"), (CS_ARCH_X86, CS_MODE_16, CS_OPT_SYNTAX_INTEL, 0xffe1, b"\x0f\x01\x0d", "sidt [di]"), - (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x0f\x01\x15\xa0\x90\x04\x08", "lgdt [rip+0x80490a0]"), + (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x0f\x01\x15\xa0\x90\x04\x08", "lgdt [rip + 0x80490a0]"), (CS_ARCH_X86, CS_MODE_32, CS_OPT_SYNTAX_INTEL, 0x9123ffe1, b"\x0f\x01\x15\xa0\x90\x04\x08", "lgdt [0x80490a0]"), (CS_ARCH_X86, CS_MODE_16, CS_OPT_SYNTAX_INTEL, 0xffe1, b"\x0f\x01\x15", "lgdt [di]"), - (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x0f\x01\x1d\xa0\x90\x04\x08", "lidt [rip+0x80490a0]"), + (CS_ARCH_X86, CS_MODE_64, CS_OPT_SYNTAX_INTEL, 0x649123ffe1, b"\x0f\x01\x1d\xa0\x90\x04\x08", "lidt [rip + 0x80490a0]"), (CS_ARCH_X86, CS_MODE_32, CS_OPT_SYNTAX_INTEL, 0x9123ffe1, b"\x0f\x01\x1d\xa0\x90\x04\x08", "lidt [0x80490a0]"), (CS_ARCH_X86, CS_MODE_16, CS_OPT_SYNTAX_INTEL, 0xffe1, b"\x0f\x01\x1d", "lidt [di]"), )