x86: add immediate operand (1) for SHL/SHR/ROR/ROL/SAR/SAL in detail mode & Intel syntax
diff --git a/arch/AArch64/AArch64InstPrinter.c b/arch/AArch64/AArch64InstPrinter.c
index 8db1887..edcb8b9 100644
--- a/arch/AArch64/AArch64InstPrinter.c
+++ b/arch/AArch64/AArch64InstPrinter.c
@@ -850,7 +850,7 @@
#define PRINT_ALIAS_INSTR
#include "AArch64GenAsmWriter.inc"
-void AArch64_post_printer(csh handle, cs_insn *flat_insn, char *insn_asm)
+void AArch64_post_printer(csh handle, cs_insn *flat_insn, char *insn_asm, MCInst *mci)
{
if (((cs_struct *)handle)->detail != CS_OPT_ON)
return;
diff --git a/arch/AArch64/AArch64InstPrinter.h b/arch/AArch64/AArch64InstPrinter.h
index 961c172..814793c 100644
--- a/arch/AArch64/AArch64InstPrinter.h
+++ b/arch/AArch64/AArch64InstPrinter.h
@@ -23,6 +23,6 @@
void AArch64_printInst(MCInst *MI, SStream *O, void *);
-void AArch64_post_printer(csh handle, cs_insn *pub_insn, char *insn_asm);
+void AArch64_post_printer(csh handle, cs_insn *pub_insn, char *insn_asm, MCInst *mci);
#endif
diff --git a/arch/ARM/ARMInstPrinter.c b/arch/ARM/ARMInstPrinter.c
index 162a4c2..7e92e1c 100644
--- a/arch/ARM/ARMInstPrinter.c
+++ b/arch/ARM/ARMInstPrinter.c
@@ -233,7 +233,7 @@
{ ARM_INS_UMULL, "umulls" },
};
-void ARM_post_printer(csh ud, cs_insn *insn, char *insn_asm)
+void ARM_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
{
if (((cs_struct *)ud)->detail != CS_OPT_ON)
return;
diff --git a/arch/ARM/ARMInstPrinter.h b/arch/ARM/ARMInstPrinter.h
index 6d6700c..e422fce 100644
--- a/arch/ARM/ARMInstPrinter.h
+++ b/arch/ARM/ARMInstPrinter.h
@@ -22,7 +22,7 @@
#include "../../SStream.h"
void ARM_printInst(MCInst *MI, SStream *O, void *Info);
-void ARM_post_printer(csh handle, cs_insn *pub_insn, char *mnem);
+void ARM_post_printer(csh handle, cs_insn *pub_insn, char *mnem, MCInst *mci);
// setup handle->get_regname
void ARM_getRegName(cs_struct *handle, int value);
diff --git a/arch/PowerPC/PPCInstPrinter.c b/arch/PowerPC/PPCInstPrinter.c
index 84d98ca..784e654 100644
--- a/arch/PowerPC/PPCInstPrinter.c
+++ b/arch/PowerPC/PPCInstPrinter.c
@@ -54,7 +54,7 @@
}
}
-void PPC_post_printer(csh ud, cs_insn *insn, char *insn_asm)
+void PPC_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
{
if (((cs_struct *)ud)->detail != CS_OPT_ON)
return;
diff --git a/arch/PowerPC/PPCInstPrinter.h b/arch/PowerPC/PPCInstPrinter.h
index 7699d79..59d38b0 100644
--- a/arch/PowerPC/PPCInstPrinter.h
+++ b/arch/PowerPC/PPCInstPrinter.h
@@ -10,6 +10,6 @@
void PPC_printInst(MCInst *MI, SStream *O, void *Info);
-void PPC_post_printer(csh ud, cs_insn *insn, char *insn_asm);
+void PPC_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci);
#endif
diff --git a/arch/Sparc/SparcInstPrinter.c b/arch/Sparc/SparcInstPrinter.c
index 5499216..b5e8498 100644
--- a/arch/Sparc/SparcInstPrinter.c
+++ b/arch/Sparc/SparcInstPrinter.c
@@ -52,7 +52,7 @@
}
}
-void Sparc_post_printer(csh ud, cs_insn *insn, char *insn_asm)
+void Sparc_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
{
if (((cs_struct *)ud)->detail != CS_OPT_ON)
return;
diff --git a/arch/Sparc/SparcInstPrinter.h b/arch/Sparc/SparcInstPrinter.h
index 4e6a5ce..5fbabd3 100644
--- a/arch/Sparc/SparcInstPrinter.h
+++ b/arch/Sparc/SparcInstPrinter.h
@@ -10,6 +10,6 @@
void Sparc_printInst(MCInst *MI, SStream *O, void *Info);
-void Sparc_post_printer(csh ud, cs_insn *insn, char *insn_asm);
+void Sparc_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci);
#endif
diff --git a/arch/SystemZ/SystemZInstPrinter.c b/arch/SystemZ/SystemZInstPrinter.c
index ac1279d..bc15f48 100644
--- a/arch/SystemZ/SystemZInstPrinter.c
+++ b/arch/SystemZ/SystemZInstPrinter.c
@@ -31,7 +31,7 @@
static const char *getRegisterName(unsigned RegNo);
-void SystemZ_post_printer(csh ud, cs_insn *insn, char *insn_asm)
+void SystemZ_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
{
/*
if (((cs_struct *)ud)->detail != CS_OPT_ON)
diff --git a/arch/SystemZ/SystemZInstPrinter.h b/arch/SystemZ/SystemZInstPrinter.h
index 3a327ff..e5e1ddc 100644
--- a/arch/SystemZ/SystemZInstPrinter.h
+++ b/arch/SystemZ/SystemZInstPrinter.h
@@ -10,6 +10,6 @@
void SystemZ_printInst(MCInst *MI, SStream *O, void *Info);
-void SystemZ_post_printer(csh ud, cs_insn *insn, char *insn_asm);
+void SystemZ_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci);
#endif
diff --git a/arch/X86/X86Mapping.c b/arch/X86/X86Mapping.c
index 5739014..edf4e64 100644
--- a/arch/X86/X86Mapping.c
+++ b/arch/X86/X86Mapping.c
@@ -41573,8 +41573,79 @@
#endif
// post printer for X86. put all the hacky stuff here
-void X86_post_printer(csh handle, cs_insn *insn, char *insn_asm)
+void X86_post_printer(csh handle, cs_insn *insn, char *insn_asm, MCInst *mci)
{
+#ifndef CAPSTONE_DIET
+ cs_struct *ud = (cs_struct *)handle;
+
+ if (ud->detail) {
+ if (ud->syntax != CS_OPT_SYNTAX_ATT) { // default syntax is Intel
+ // AT&T print this instruction without immediate 1?
+ switch (mci->Opcode) {
+ default:
+ break;
+ case X86_SAL8r1:
+ case X86_SAL16r1:
+ case X86_SAL32r1:
+ case X86_SAL64r1:
+ case X86_SAL8m1:
+ case X86_SAL16m1:
+ case X86_SAL32m1:
+ case X86_SAL64m1:
+
+ case X86_SHL8r1:
+ case X86_SHL16r1:
+ case X86_SHL32r1:
+ case X86_SHL64r1:
+ case X86_SHL8m1:
+ case X86_SHL16m1:
+ case X86_SHL32m1:
+ case X86_SHL64m1:
+
+ case X86_SHR8r1:
+ case X86_SHR16r1:
+ case X86_SHR32r1:
+ case X86_SHR64r1:
+ case X86_SHR8m1:
+ case X86_SHR16m1:
+ case X86_SHR32m1:
+ case X86_SHR64m1:
+
+ case X86_SAR8r1:
+ case X86_SAR16r1:
+ case X86_SAR32r1:
+ case X86_SAR64r1:
+ case X86_SAR8m1:
+ case X86_SAR16m1:
+ case X86_SAR32m1:
+ case X86_SAR64m1:
+
+ case X86_ROR8r1:
+ case X86_ROR16r1:
+ case X86_ROR32r1:
+ case X86_ROR64r1:
+ case X86_ROR8m1:
+ case X86_ROR16m1:
+ case X86_ROR32m1:
+ case X86_ROR64m1:
+
+ case X86_ROL8r1:
+ case X86_ROL16r1:
+ case X86_ROL32r1:
+ case X86_ROL64r1:
+ case X86_ROL8m1:
+ case X86_ROL16m1:
+ case X86_ROL32m1:
+ case X86_ROL64m1:
+
+ insn->detail->x86.operands[insn->detail->x86.op_count].type = X86_OP_IMM;
+ insn->detail->x86.operands[insn->detail->x86.op_count].imm = 1;
+ insn->detail->x86.op_count++;
+ break;
+ }
+ }
+ }
+#endif
}
// given internal insn id, return public instruction info
diff --git a/arch/X86/X86Mapping.h b/arch/X86/X86Mapping.h
index 4fbeffe..c958a2c 100644
--- a/arch/X86/X86Mapping.h
+++ b/arch/X86/X86Mapping.h
@@ -30,7 +30,7 @@
const char *X86_insn_name(csh handle, unsigned int id);
// post printer for X86.
-void X86_post_printer(csh handle, cs_insn *pub_insn, char *insn_asm);
+void X86_post_printer(csh handle, cs_insn *pub_insn, char *insn_asm, MCInst *mci);
// return register of given instruction id
// return 0 if not found
diff --git a/cs.c b/cs.c
index c037de5..05a5f1d 100644
--- a/cs.c
+++ b/cs.c
@@ -278,7 +278,7 @@
// post printer handles some corner cases (hacky)
if (postprinter)
- postprinter((csh)handle, insn, buffer);
+ postprinter((csh)handle, insn, buffer, mci);
#ifndef CAPSTONE_DIET
// fill in mnemonic & operands
diff --git a/cs_priv.h b/cs_priv.h
index 5936254..d3cd3e1 100644
--- a/cs_priv.h
+++ b/cs_priv.h
@@ -13,7 +13,7 @@
// function to be called after Printer_t
// this is the best time to gather insn's characteristics
-typedef void (*PostPrinter_t)(csh handle, cs_insn *, char *mnem);
+typedef void (*PostPrinter_t)(csh handle, cs_insn *, char *mnem, MCInst *mci);
typedef bool (*Disasm_t)(csh handle, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info);