18 #ifdef CAPSTONE_HAS_X86
20 #if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
21 #pragma warning(disable:4996)
22 #pragma warning(disable:28719)
25 #if !defined(CAPSTONE_HAS_OSXKERNEL)
28 #include <capstone/platform.h>
30 #if defined(CAPSTONE_HAS_OSXKERNEL)
31 #include <Availability.h>
32 #include <libkern/libkern.h>
39 #include "../../utils.h"
40 #include "../../MCInst.h"
41 #include "../../SStream.h"
42 #include "../../MCRegisterInfo.h"
47 #define GET_INSTRINFO_ENUM
48 #ifdef CAPSTONE_X86_REDUCE
56 static void printMemReference(
MCInst *MI,
unsigned Op,
SStream *
O);
144 printMemReference(MI, OpNo,
O);
151 printMemReference(MI, OpNo,
O);
158 printMemReference(MI, OpNo,
O);
165 printMemReference(MI, OpNo,
O);
172 printMemReference(MI, OpNo,
O);
179 printMemReference(MI, OpNo,
O);
182 #ifndef CAPSTONE_X86_REDUCE
187 printMemReference(MI, OpNo,
O);
194 printMemReference(MI, OpNo,
O);
227 printMemReference(MI, OpNo,
O);
234 printMemReference(MI, OpNo,
O);
241 printMemReference(MI, OpNo,
O);
248 printMemReference(MI, OpNo,
O);
255 printMemReference(MI, OpNo,
O);
262 printMemReference(MI, OpNo,
O);
342 static void printRoundingControl(
MCInst *MI,
unsigned Op,
SStream *
O)
356 static const char *getRegisterName(
unsigned RegNo);
357 static void printRegName(
SStream *
OS,
unsigned RegNo)
398 if (
imm == 0x8000000000000000LL)
400 else if (need_zero_prefix(
imm))
406 if (need_zero_prefix(
imm))
442 if (
imm == 0x8000000000000000LL)
445 if (need_zero_prefix(
imm))
453 if (need_zero_prefix(
imm))
462 if (
imm == 0x8000000000000000LL)
491 #ifndef CAPSTONE_DIET
495 #ifndef CAPSTONE_DIET
524 #ifndef CAPSTONE_DIET
533 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].mem.scale = 1;
534 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].mem.disp = 0;
536 #ifndef CAPSTONE_DIET
547 _printOperand(MI, Op+1,
O);
555 set_mem_access(MI,
true);
556 printOperand(MI, Op,
O);
558 set_mem_access(MI,
false);
564 #ifndef CAPSTONE_DIET
573 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].mem.scale = 1;
574 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].mem.disp = 0;
576 #ifndef CAPSTONE_DIET
591 set_mem_access(MI,
true);
592 printOperand(MI, Op,
O);
594 set_mem_access(MI,
false);
601 printSrcIdx(MI, OpNo,
O);
608 printSrcIdx(MI, OpNo,
O);
615 printSrcIdx(MI, OpNo,
O);
622 printSrcIdx(MI, OpNo,
O);
629 printDstIdx(MI, OpNo,
O);
636 printDstIdx(MI, OpNo,
O);
643 printDstIdx(MI, OpNo,
O);
650 printDstIdx(MI, OpNo,
O);
660 #ifndef CAPSTONE_DIET
669 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].mem.scale = 1;
670 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].mem.disp = 0;
672 #ifndef CAPSTONE_DIET
681 _printOperand(MI, Op + 1,
O);
698 printImm(MI,
O,
imm,
true);
710 #ifndef CAPSTONE_X86_REDUCE
715 printImm(MI,
O,
val,
true);
718 #ifndef CAPSTONE_DIET
726 #ifndef CAPSTONE_DIET
740 printMemOffset(MI, OpNo,
O);
747 printMemOffset(MI, OpNo,
O);
754 printMemOffset(MI, OpNo,
O);
761 printMemOffset(MI, OpNo,
O);
764 #ifndef CAPSTONE_DIET
771 #ifndef CAPSTONE_DIET
779 strncpy(
O->buffer, MI->
assembly,
sizeof(
O->buffer));
783 #ifndef CAPSTONE_DIET
785 mnem = printAliasInstr(MI,
O, Info);
790 printInstruction(MI,
O, Info);
794 #ifndef CAPSTONE_DIET
802 memmove(&(MI->
flat_insn->detail->x86.operands[1]), &(MI->
flat_insn->detail->x86.operands[0]),
807 MI->
flat_insn->detail->x86.operands[0].access = access1;
814 MI->
flat_insn->detail->x86.operands[0].access = access1;
816 MI->
flat_insn->detail->x86.operands[1].reg = reg2;
818 MI->
flat_insn->detail->x86.operands[1].access = access2;
823 #ifndef CAPSTONE_DIET
849 (MI->
Opcode != X86_JMP_4 && MI->
Opcode != X86_CALLpcrel32))
858 if (MI->
Opcode == X86_CALLpcrel16 || MI->
Opcode == X86_JMP_2)
864 printImm(MI,
O,
imm,
true);
867 #ifndef CAPSTONE_DIET
873 if (MI->
flat_insn->detail->x86.op_count > 0)
876 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].size = opsize;
881 #ifndef CAPSTONE_DIET
901 printRegName(
O,
reg);
906 #ifndef CAPSTONE_DIET
914 #ifndef CAPSTONE_DIET
941 printImm(MI,
O,
imm,
true);
949 printImm(MI,
O,
imm,
true);
959 printImm(MI,
O,
imm,
true);
967 printImm(MI,
O,
imm,
true);
970 printImm(MI,
O,
imm,
true);
978 printImm(MI,
O,
imm,
true);
981 printImm(MI,
O,
imm,
true);
990 #ifndef CAPSTONE_DIET
996 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].size = opsize;
997 MI->
flat_insn->detail->x86.encoding.imm_size = encsize;
998 }
else if (MI->
flat_insn->detail->x86.op_count > 0) {
1001 MI->
flat_insn->detail->x86.operands[0].size;
1008 #ifndef CAPSTONE_DIET
1019 static void printMemReference(
MCInst *MI,
unsigned Op,
SStream *
O)
1021 bool NeedPlus =
false;
1030 #ifndef CAPSTONE_DIET
1040 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].mem.disp = 0;
1042 #ifndef CAPSTONE_DIET
1076 MI->
flat_insn->detail->x86.operands[MI->
flat_insn->detail->x86.op_count].mem.disp = DispVal;
1081 printImm(MI,
O, -DispVal,
true);
1084 printImm(MI,
O, DispVal,
true);
1091 printImm(MI,
O, DispVal,
true);
1126 printMemReference(MI, OpNo,
O);
1129 #define GET_REGINFO_ENUM
1132 #define PRINT_ALIAS_INSTR
1133 #ifdef CAPSTONE_X86_REDUCE
unsigned MCInst_getOpcode(const MCInst *inst)
MCOperand * MCInst_getOperand(MCInst *inst, unsigned i)
bool MCOperand_isReg(const MCOperand *op)
int64_t MCOperand_getImm(MCOperand *op)
unsigned MCOperand_getReg(const MCOperand *op)
getReg - Returns the register number.
bool MCOperand_isImm(const MCOperand *op)
void SStream_concat(SStream *ss, const char *fmt,...)
void SStream_concat0(SStream *ss, const char *s)
@ X86_AddrSegmentReg
AddrSegmentReg - The operand # of the segment in the memory operand.
void X86_Intel_printInst(MCInst *MI, SStream *OS, void *Info)
uint8_t X86_immediate_size(unsigned int id, uint8_t *enc_size)
const uint64_t arch_masks[9]
void op_addSseCC(MCInst *MI, int v)
void op_addAvxRoundingMode(MCInst *MI, int v)
uint8_t * X86_get_op_access(cs_struct *h, unsigned int id, uint64_t *eflags)
void op_addAvxSae(MCInst *MI)
void op_addXopCC(MCInst *MI, int v)
bool X86_insn_reg_intel2(unsigned int id, x86_reg *reg1, enum cs_ac_type *access1, x86_reg *reg2, enum cs_ac_type *access2)
x86_reg X86_insn_reg_intel(unsigned int id, enum cs_ac_type *access)
void op_addAvxCC(MCInst *MI, int v)
RzBinInfo * info(RzBinFile *bf)
@ CS_MODE_64
64-bit mode (X86, PPC)
@ CS_MODE_32
32-bit mode (X86)
@ CS_MODE_16
16-bit mode (X86)
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
@ CS_OPT_SYNTAX_MASM
X86 Intel Masm syntax (CS_OPT_SYNTAX).
@ X86_AVX_RM_RD
Round down.
@ X86_AVX_RM_RN
Round to nearest.
@ X86_AVX_RM_RZ
Round toward zero.
@ X86_OP_IMM
= CS_OP_IMM (Immediate operand).
@ X86_OP_REG
= CS_OP_REG (Register operand).
@ X86_OP_MEM
= CS_OP_MEM (Memory operand).
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause access
static const char struct stat static buf struct stat static buf static vhangup int status
cs_opt_value imm_unsigned
const uint8_t * regsize_map