17 #ifdef CAPSTONE_HAS_ARM
22 #include <capstone/platform.h>
28 #include "../../MCInst.h"
29 #include "../../SStream.h"
30 #include "../../MCRegisterInfo.h"
31 #include "../../utils.h"
34 #define GET_SUBTARGETINFO_ENUM
43 static void printSORegRegOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
44 static void printSORegImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
46 static void printAddrModeTBB(
MCInst *MI,
unsigned OpNum,
SStream *
O);
47 static void printAddrModeTBH(
MCInst *MI,
unsigned OpNum,
SStream *
O);
48 static void printAddrMode2Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
49 static void printAM2PreOrOffsetIndexOp(
MCInst *MI,
unsigned OpNum,
SStream *
O);
50 static void printAddrMode2OffsetOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
51 static void printAddrMode3Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
bool AlwaysPrintImm0);
52 static void printAddrMode3OffsetOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
53 static void printAM3PreOrOffsetIndexOp(
MCInst *MI,
unsigned Op,
SStream *
O,
bool AlwaysPrintImm0);
54 static void printPostIdxImm8Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
55 static void printPostIdxRegOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
56 static void printPostIdxImm8s4Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
57 static void printAddrMode5Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
bool AlwaysPrintImm0);
58 static void printAddrMode6Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
59 static void printAddrMode7Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
60 static void printAddrMode6OffsetOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
62 static void printBitfieldInvMaskImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
63 static void printMemBOption(
MCInst *MI,
unsigned OpNum,
SStream *
O);
64 static void printShiftImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
65 static void printPKHLSLShiftImm(
MCInst *MI,
unsigned OpNum,
SStream *
O);
66 static void printPKHASRShiftImm(
MCInst *MI,
unsigned OpNum,
SStream *
O);
67 static void printAdrLabelOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
unsigned);
68 static void printThumbS4ImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
69 static void printThumbSRImm(
MCInst *MI,
unsigned OpNum,
SStream *
O);
70 static void printThumbITMask(
MCInst *MI,
unsigned OpNum,
SStream *
O);
71 static void printThumbAddrModeRROperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
72 static void printThumbAddrModeImm5SOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
unsigned Scale);
73 static void printThumbAddrModeImm5S1Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
74 static void printThumbAddrModeImm5S2Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
75 static void printThumbAddrModeImm5S4Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
76 static void printThumbAddrModeSPOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
77 static void printT2SOOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
78 static void printAddrModeImm12Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
bool AlwaysPrintImm0);
79 static void printT2AddrModeImm8Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
bool);
80 static void printT2AddrModeImm8s4Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
bool);
81 static void printT2AddrModeImm0_1020s4Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
82 static void printT2AddrModeImm8OffsetOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
83 static void printT2AddrModeImm8s4OffsetOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
84 static void printT2AddrModeSoRegOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
85 static void printSetendOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
88 static void printMSRMaskOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
89 static void printPredicateOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
90 static void printMandatoryPredicateOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
91 static void printSBitModifierOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
92 static void printRegisterList(
MCInst *MI,
unsigned OpNum,
SStream *
O);
93 static void printNoHashImmediate(
MCInst *MI,
unsigned OpNum,
SStream *
O);
94 static void printPImmediate(
MCInst *MI,
unsigned OpNum,
SStream *
O);
95 static void printCImmediate(
MCInst *MI,
unsigned OpNum,
SStream *
O);
96 static void printCoprocOptionImm(
MCInst *MI,
unsigned OpNum,
SStream *
O);
97 static void printFPImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
98 static void printNEONModImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
99 static void printImmPlusOneOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
100 static void printRotImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
102 static void printThumbLdrLabelOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
105 static void printVectorIndex(
MCInst *MI,
unsigned OpNum,
SStream *
O);
106 static void printVectorListOne(
MCInst *MI,
unsigned OpNum,
SStream *
O);
109 static void printVectorListThree(
MCInst *MI,
unsigned OpNum,
SStream *
O);
110 static void printVectorListFour(
MCInst *MI,
unsigned OpNum,
SStream *
O);
111 static void printVectorListOneAllLanes(
MCInst *MI,
unsigned OpNum,
SStream *
O);
113 static void printVectorListThreeAllLanes(
MCInst *MI,
unsigned OpNum,
SStream *
O);
114 static void printVectorListFourAllLanes(
MCInst *MI,
unsigned OpNum,
SStream *
O);
116 static void printVectorListThreeSpacedAllLanes(
MCInst *MI,
unsigned OpNum,
SStream *
O);
117 static void printVectorListFourSpacedAllLanes(
MCInst *MI,
unsigned OpNum,
SStream *
O);
118 static void printVectorListThreeSpaced(
MCInst *MI,
unsigned OpNum,
SStream *
O);
119 static void printVectorListFourSpaced(
MCInst *MI,
unsigned OpNum,
SStream *
O);
120 static void printBankedRegOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
121 static void printModImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O);
123 static void printInstSyncBOption(
MCInst *MI,
unsigned OpNum,
SStream *
O);
125 #ifndef CAPSTONE_DIET
145 #ifndef CAPSTONE_DIET
152 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.scale = 1;
153 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.disp = 0;
155 #ifndef CAPSTONE_DIET
175 #define GET_INSTRINFO_ENUM
184 handle->get_regname = getRegisterName2;
187 handle->get_regname = getRegisterName;
195 static unsigned translateShiftImm(
unsigned imm)
225 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].shift.value = translateShiftImm(ShImm);
227 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count - 1].shift.value = translateShiftImm(ShImm);
234 #ifndef CAPSTONE_DIET
239 static const name_map insn_update_flgs[] = {
280 insn->detail->arm.writeback =
true;
287 case ARM_t2LDC2L_PRE:
295 case ARM_t2LDRSB_PRE:
296 case ARM_t2LDRSH_PRE:
299 case ARM_t2STC2L_PRE:
309 case ARM_t2LDC2L_POST:
310 case ARM_t2LDC2_POST:
311 case ARM_t2LDCL_POST:
314 case ARM_t2LDRB_POST:
315 case ARM_t2LDRD_POST:
316 case ARM_t2LDRH_POST:
317 case ARM_t2LDRSB_POST:
318 case ARM_t2LDRSH_POST:
321 case ARM_t2STC2L_POST:
322 case ARM_t2STC2_POST:
323 case ARM_t2STCL_POST:
326 case ARM_t2STRB_POST:
327 case ARM_t2STRD_POST:
328 case ARM_t2STRH_POST:
330 insn->detail->arm.writeback =
true;
377 case ARM_LDRB_POST_IMM:
378 case ARM_LDR_POST_IMM:
379 case ARM_LDR_POST_REG:
380 case ARM_STRB_POST_IMM:
382 case ARM_STR_POST_IMM:
383 case ARM_STR_POST_REG:
385 insn->detail->arm.writeback =
true;
391 if (insn->detail->arm.update_flags ==
false) {
396 if (insn->id == insn_update_flgs[
i].id &&
397 !strncmp(insn_asm, insn_update_flgs[
i].
name,
398 strlen(insn_update_flgs[
i].
name))) {
399 insn->detail->arm.update_flags =
true;
401 for (j = 0; j <
ARR_SIZE(insn->detail->regs_write); j++) {
402 if (insn->detail->regs_write[j] == 0) {
423 insn->detail->arm.operands[0].type =
ARM_OP_REG;
424 insn->detail->arm.operands[0].reg =
ARM_REG_PC;
425 insn->detail->arm.operands[0].access =
CS_AC_WRITE;
426 insn->detail->arm.operands[1].type =
ARM_OP_REG;
427 insn->detail->arm.operands[1].reg =
ARM_REG_LR;
428 insn->detail->arm.operands[1].access =
CS_AC_READ;
429 insn->detail->arm.op_count = 2;
461 printInstruction(MI,
O, MRI);
464 printPredicateOperand(MI, 1,
O);
502 printSBitModifierOperand(MI, 6,
O);
503 printPredicateOperand(MI, 4,
O);
564 printSBitModifierOperand(MI, 5,
O);
565 printPredicateOperand(MI, 3,
O);
594 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count - 1].shift.type =
603 case ARM_t2STMDB_UPD:
609 printPredicateOperand(MI, 2,
O);
610 if (
Opcode == ARM_t2STMDB_UPD)
616 MI->
flat_insn->detail->regs_read_count++;
618 MI->
flat_insn->detail->regs_write_count++;
621 printRegisterList(MI, 4,
O);
626 case ARM_STR_PRE_IMM:
631 printPredicateOperand(MI, 4,
O);
635 #ifndef CAPSTONE_DIET
640 #ifndef CAPSTONE_DIET
654 case ARM_t2LDMIA_UPD:
660 printPredicateOperand(MI, 2,
O);
661 if (
Opcode == ARM_t2LDMIA_UPD)
668 MI->
flat_insn->detail->regs_read_count++;
670 MI->
flat_insn->detail->regs_write_count++;
673 printRegisterList(MI, 4,
O);
678 case ARM_LDR_POST_IMM:
686 printPredicateOperand(MI, 5,
O);
696 MI->
flat_insn->detail->regs_read_count++;
698 MI->
flat_insn->detail->regs_write_count++;
707 case ARM_VSTMSDB_UPD:
708 case ARM_VSTMDDB_UPD:
712 printPredicateOperand(MI, 2,
O);
714 printRegisterList(MI, 4,
O);
720 case ARM_VLDMSIA_UPD:
721 case ARM_VLDMDIA_UPD:
725 printPredicateOperand(MI, 2,
O);
727 printRegisterList(MI, 4,
O);
733 bool Writeback =
true;
744 printPredicateOperand(MI, 1,
O);
746 printRegName(MI->
csh,
O, BaseReg);
749 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].reg = BaseReg;
758 printRegisterList(MI, 3,
O);
773 bool isStore =
Opcode == ARM_STREXD ||
Opcode == ARM_STLEXD;
792 printInstruction(&NewMI,
O, MRI);
800 case ARM_t2SUBS_PC_LR: {
808 printPredicateOperand(MI, 1,
O);
817 printInstruction(MI,
O, MRI);
834 #ifndef CAPSTONE_DIET
840 #ifndef CAPSTONE_DIET
866 #define _ALIGN_DOWN(v, align_width) ((v/align_width)*align_width)
867 address = _ALIGN_DOWN(address, 4);
907 static void printThumbLdrLabelOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
932 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.scale = 1;
933 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.disp = OffImm;
944 static void printSORegRegOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
976 static void printSORegImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1000 static void printAM2PreOrOffsetIndexOp(
MCInst *MI,
unsigned Op,
SStream *
O)
1008 set_mem_access(MI,
true);
1032 set_mem_access(MI,
false);
1047 set_mem_access(MI,
false);
1050 static void printAddrModeTBB(
MCInst *MI,
unsigned Op,
SStream *
O)
1055 set_mem_access(MI,
true);
1064 set_mem_access(MI,
false);
1067 static void printAddrModeTBH(
MCInst *MI,
unsigned Op,
SStream *
O)
1072 set_mem_access(MI,
true);
1083 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].shift.value = 1;
1084 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.lshift = 1;
1086 set_mem_access(MI,
false);
1089 static void printAddrMode2Operand(
MCInst *MI,
unsigned Op,
SStream *
O)
1094 printOperand(MI, Op,
O);
1098 printAM2PreOrOffsetIndexOp(MI, Op,
O);
1101 static void printAddrMode2OffsetOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1117 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].imm = ImmOffs;
1142 static void printAM3PreOrOffsetIndexOp(
MCInst *MI,
unsigned Op,
SStream *
O,
1143 bool AlwaysPrintImm0)
1152 set_mem_access(MI,
true);
1164 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.scale = -1;
1165 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].subtracted =
true;
1169 set_mem_access(MI,
false);
1176 if (AlwaysPrintImm0 || ImmOffs || (sign ==
ARM_AM_sub)) {
1186 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].subtracted =
true;
1192 set_mem_access(MI,
false);
1195 static void printAddrMode3Operand(
MCInst *MI,
unsigned Op,
SStream *
O,
1196 bool AlwaysPrintImm0)
1200 printOperand(MI, Op,
O);
1204 printAM3PreOrOffsetIndexOp(MI, Op,
O, AlwaysPrintImm0);
1207 static void printAddrMode3OffsetOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1234 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].imm = ImmOffs;
1240 static void printPostIdxImm8Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1250 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].imm = Imm & 0xff;
1255 static void printPostIdxRegOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1270 static void printPostIdxImm8s4Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1276 SStream_concat(
O,
"#%s0x%x", ((Imm & 256) ?
"" :
"-"), ((Imm & 0xff) << 2));
1278 SStream_concat(
O,
"#%s%u", ((Imm & 256) ?
"" :
"-"), ((Imm & 0xff) << 2));
1282 int v = (Imm & 256) ? ((Imm & 0xff) << 2) : -((Imm & 0xff) << 2);
1289 static void printAddrMode5Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
1290 bool AlwaysPrintImm0)
1298 printOperand(MI, OpNum,
O);
1309 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.scale = 1;
1310 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.disp = 0;
1315 if (AlwaysPrintImm0 || ImmOffs || subtracted ==
ARM_AM_sub) {
1326 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.disp = ImmOffs * 4;
1328 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.disp = -(
int)ImmOffs * 4;
1338 static void printAddrMode6Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1345 set_mem_access(MI,
true);
1359 set_mem_access(MI,
false);
1362 static void printAddrMode7Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1366 set_mem_access(MI,
true);
1371 set_mem_access(MI,
false);
1374 static void printAddrMode6OffsetOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1392 static void printBitfieldInvMaskImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1417 static void printMemBOption(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1428 void printInstSyncBOption(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1434 static void printShiftImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1437 bool isASR = (ShiftOp & (1 << 5)) != 0;
1438 unsigned Amt = ShiftOp & 0x1f;
1440 unsigned tmp = Amt == 0 ? 32 : Amt;
1456 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count - 1].shift.value = Amt;
1461 static void printPKHLSLShiftImm(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1473 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count - 1].shift.value = Imm;
1477 static void printPKHASRShiftImm(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1490 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count - 1].shift.value = Imm;
1495 static void printRegisterList(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1498 #ifndef CAPSTONE_DIET
1504 #ifndef CAPSTONE_DIET
1516 #ifndef CAPSTONE_DIET
1524 #ifndef CAPSTONE_DIET
1531 static void printGPRPairOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
1551 static void printSetendOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1583 static void printCPSIFlag(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1589 for (
i = 2;
i >= 0; --
i)
1590 if (IFlags & (1 <<
i)) {
1600 MI->
flat_insn->detail->arm.cps_flag = IFlags;
1604 static void printMSRMaskOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1612 if (FeatureBits & ARM_FeatureMClass) {
1617 if (
Opcode == ARM_t2MSR_M && (FeatureBits & ARM_FeatureDSPThumb2)) {
1633 if (
Opcode == ARM_t2MSR_M && (FeatureBits & ARM_HasV7Ops)) {
1666 if (!SpecRegRBit && (Mask == 8 || Mask == 4 || Mask == 12)) {
1730 static void printBankedRegOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1735 const char *RegNames[] = {
1736 "r8_usr",
"r9_usr",
"r10_usr",
"r11_usr",
"r12_usr",
"sp_usr",
"lr_usr",
"",
1737 "r8_fiq",
"r9_fiq",
"r10_fiq",
"r11_fiq",
"r12_fiq",
"sp_fiq",
"lr_fiq",
"",
1738 "lr_irq",
"sp_irq",
"lr_svc",
"sp_svc",
"lr_abt",
"sp_abt",
"lr_und",
"sp_und",
1739 "",
"",
"",
"",
"lr_mon",
"sp_mon",
"elr_hyp",
"sp_hyp"
1752 const char *Name = RegNames[SysM];
1778 static void printPredicateOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1782 if ((
unsigned)CC == 15) {
1796 static void printMandatoryPredicateOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1804 static void printSBitModifierOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1811 MI->
flat_insn->detail->arm.update_flags =
true;
1815 static void printNoHashImmediate(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1832 static void printPImmediate(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1844 static void printCImmediate(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1856 static void printCoprocOptionImm(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1870 static void printAdrLabelOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
unsigned scale)
1894 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].imm = OffImm;
1900 static void printThumbS4ImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1913 static void printThumbSRImm(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1916 unsigned tmp = Imm == 0 ? 32 : Imm;
1927 static void printThumbITMask(
MCInst *MI,
unsigned OpNum,
SStream *
O)
1932 unsigned CondBit0 = Firstcond & 1;
1937 bool T = ((Mask >>
Pos) & 1) == CondBit0;
1945 static void printThumbAddrModeRROperand(
MCInst *MI,
unsigned Op,
SStream *
O)
1952 printOperand(MI, Op,
O);
1957 set_mem_access(MI,
true);
1964 printRegName(MI->
csh,
O, RegNum);
1966 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.index = RegNum;
1969 set_mem_access(MI,
false);
1972 static void printThumbAddrModeImm5SOperand(
MCInst *MI,
unsigned Op,
SStream *
O,
1977 unsigned ImmOffs,
tmp;
1980 printOperand(MI, Op,
O);
1985 set_mem_access(MI,
true);
1991 tmp = ImmOffs * Scale;
1998 set_mem_access(MI,
false);
2001 static void printThumbAddrModeImm5S1Operand(
MCInst *MI,
unsigned Op,
SStream *
O)
2003 printThumbAddrModeImm5SOperand(MI, Op,
O, 1);
2006 static void printThumbAddrModeImm5S2Operand(
MCInst *MI,
unsigned Op,
SStream *
O)
2008 printThumbAddrModeImm5SOperand(MI, Op,
O, 2);
2011 static void printThumbAddrModeImm5S4Operand(
MCInst *MI,
unsigned Op,
SStream *
O)
2013 printThumbAddrModeImm5SOperand(MI, Op,
O, 4);
2016 static void printThumbAddrModeSPOperand(
MCInst *MI,
unsigned Op,
SStream *
O)
2018 printThumbAddrModeImm5SOperand(MI, Op,
O, 4);
2025 static void printT2SOOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2031 printRegName(MI->
csh,
O,
Reg);
2045 static void printAddrModeImm12Operand(
MCInst *MI,
unsigned OpNum,
2054 printOperand(MI, OpNum,
O);
2059 set_mem_access(MI,
true);
2075 }
else if (AlwaysPrintImm0 || OffImm > 0) {
2089 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.disp = OffImm;
2091 set_mem_access(MI,
false);
2094 static void printT2AddrModeImm8Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O,
2095 bool AlwaysPrintImm0)
2103 set_mem_access(MI,
true);
2117 else if (AlwaysPrintImm0 || OffImm > 0) {
2125 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.disp = OffImm;
2127 set_mem_access(MI,
false);
2130 static void printT2AddrModeImm8s4Operand(
MCInst *MI,
2131 unsigned OpNum,
SStream *
O,
bool AlwaysPrintImm0)
2139 printOperand(MI, OpNum,
O);
2144 set_mem_access(MI,
true);
2159 }
else if (AlwaysPrintImm0 || OffImm > 0) {
2166 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].mem.disp = OffImm;
2169 set_mem_access(MI,
false);
2172 static void printT2AddrModeImm0_1020s4Operand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2179 set_mem_access(MI,
true);
2191 set_mem_access(MI,
false);
2194 static void printT2AddrModeImm8OffsetOperand(
MCInst *MI,
2211 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].imm = OffImm;
2217 static void printT2AddrModeImm8s4OffsetOperand(
MCInst *MI,
2237 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].imm = OffImm;
2243 static void printT2AddrModeSoRegOperand(
MCInst *MI,
2252 set_mem_access(MI,
true);
2270 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].shift.value = ShAmt;
2275 set_mem_access(MI,
false);
2278 static void printFPImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2282 #if defined(_KERNEL_MODE)
2295 static void printNEONModImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2311 static void printImmPlusOneOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2317 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].imm = Imm + 1;
2322 static void printRotImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2336 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count - 1].shift.value = Imm * 8;
2340 static void printModImmOperand(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2347 bool PrintUnsigned =
false;
2355 PrintUnsigned =
true;
2359 Rotated =
rotr32(Bits, Rot);
2362 if (PrintUnsigned) {
2367 }
else if (Rotated >= 0) {
2377 MI->
flat_insn->detail->arm.operands[MI->
flat_insn->detail->arm.op_count].imm = Rotated;
2423 static void printVectorIndex(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2435 static void printVectorListOne(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2440 #ifndef CAPSTONE_DIET
2448 #ifndef CAPSTONE_DIET
2453 #ifndef CAPSTONE_DIET
2460 static void printVectorListTwo(
MCInst *MI,
unsigned OpNum,
2463 #ifndef CAPSTONE_DIET
2470 #ifndef CAPSTONE_DIET
2475 printRegName(MI->
csh,
O, Reg0);
2479 #ifndef CAPSTONE_DIET
2485 printRegName(MI->
csh,
O, Reg1);
2489 #ifndef CAPSTONE_DIET
2496 #ifndef CAPSTONE_DIET
2501 static void printVectorListTwoSpaced(
MCInst *MI,
unsigned OpNum,
2504 #ifndef CAPSTONE_DIET
2511 #ifndef CAPSTONE_DIET
2516 printRegName(MI->
csh,
O, Reg0);
2520 #ifndef CAPSTONE_DIET
2526 printRegName(MI->
csh,
O, Reg1);
2530 #ifndef CAPSTONE_DIET
2537 #ifndef CAPSTONE_DIET
2542 static void printVectorListThree(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2544 #ifndef CAPSTONE_DIET
2558 #ifndef CAPSTONE_DIET
2568 #ifndef CAPSTONE_DIET
2578 #ifndef CAPSTONE_DIET
2585 #ifndef CAPSTONE_DIET
2590 static void printVectorListFour(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2592 #ifndef CAPSTONE_DIET
2606 #ifndef CAPSTONE_DIET
2616 #ifndef CAPSTONE_DIET
2626 #ifndef CAPSTONE_DIET
2636 #ifndef CAPSTONE_DIET
2643 #ifndef CAPSTONE_DIET
2648 static void printVectorListOneAllLanes(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2650 #ifndef CAPSTONE_DIET
2661 #ifndef CAPSTONE_DIET
2668 #ifndef CAPSTONE_DIET
2673 static void printVectorListTwoAllLanes(
MCInst *MI,
unsigned OpNum,
2676 #ifndef CAPSTONE_DIET
2683 #ifndef CAPSTONE_DIET
2688 printRegName(MI->
csh,
O, Reg0);
2692 #ifndef CAPSTONE_DIET
2698 printRegName(MI->
csh,
O, Reg1);
2702 #ifndef CAPSTONE_DIET
2709 #ifndef CAPSTONE_DIET
2714 static void printVectorListThreeAllLanes(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2716 #ifndef CAPSTONE_DIET
2730 #ifndef CAPSTONE_DIET
2740 #ifndef CAPSTONE_DIET
2750 #ifndef CAPSTONE_DIET
2757 #ifndef CAPSTONE_DIET
2762 static void printVectorListFourAllLanes(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2764 #ifndef CAPSTONE_DIET
2778 #ifndef CAPSTONE_DIET
2788 #ifndef CAPSTONE_DIET
2798 #ifndef CAPSTONE_DIET
2808 #ifndef CAPSTONE_DIET
2815 #ifndef CAPSTONE_DIET
2820 static void printVectorListTwoSpacedAllLanes(
MCInst *MI,
2823 #ifndef CAPSTONE_DIET
2830 #ifndef CAPSTONE_DIET
2835 printRegName(MI->
csh,
O, Reg0);
2839 #ifndef CAPSTONE_DIET
2845 printRegName(MI->
csh,
O, Reg1);
2849 #ifndef CAPSTONE_DIET
2856 #ifndef CAPSTONE_DIET
2861 static void printVectorListThreeSpacedAllLanes(
MCInst *MI,
2864 #ifndef CAPSTONE_DIET
2878 #ifndef CAPSTONE_DIET
2888 #ifndef CAPSTONE_DIET
2898 #ifndef CAPSTONE_DIET
2905 #ifndef CAPSTONE_DIET
2910 static void printVectorListFourSpacedAllLanes(
MCInst *MI,
2913 #ifndef CAPSTONE_DIET
2927 #ifndef CAPSTONE_DIET
2937 #ifndef CAPSTONE_DIET
2947 #ifndef CAPSTONE_DIET
2957 #ifndef CAPSTONE_DIET
2964 #ifndef CAPSTONE_DIET
2969 static void printVectorListThreeSpaced(
MCInst *MI,
unsigned OpNum,
SStream *
O)
2971 #ifndef CAPSTONE_DIET
2985 #ifndef CAPSTONE_DIET
2995 #ifndef CAPSTONE_DIET
3005 #ifndef CAPSTONE_DIET
3012 #ifndef CAPSTONE_DIET
3017 static void printVectorListFourSpaced(
MCInst *MI,
unsigned OpNum,
SStream *
O)
3019 #ifndef CAPSTONE_DIET
3033 #ifndef CAPSTONE_DIET
3043 #ifndef CAPSTONE_DIET
3053 #ifndef CAPSTONE_DIET
3063 #ifndef CAPSTONE_DIET
3070 #ifndef CAPSTONE_DIET
3078 MI->
flat_insn->detail->arm.vector_data = vd;
3101 MI->
flat_insn->detail->arm.usermode =
true;
static uint64_t ARM_AM_decodeNEONModImm(unsigned ModImm, unsigned *EltBits)
static ARM_AM_ShiftOpc getAM2ShiftOpc(unsigned AM2Opc)
static unsigned char getAM3Offset(unsigned AM3Opc)
static unsigned getSORegOffset(unsigned Op)
static ARM_AM_ShiftOpc ARM_AM_getSORegShOp(unsigned Op)
static const char * ARM_AM_getAddrOpcStr(ARM_AM_AddrOpc Op)
ARM_AM_ShiftOpc
ARM_AM - ARM Addressing Mode Stuff.
static unsigned rotr32(unsigned Val, unsigned Amt)
static const char * ARM_AM_getShiftOpcStr(ARM_AM_ShiftOpc Op)
static unsigned char ARM_AM_getAM5Offset(unsigned AM5Opc)
static ARM_AM_AddrOpc getAM2Op(unsigned AM2Opc)
static ARM_AM_AddrOpc getAM3Op(unsigned AM3Opc)
static ARM_AM_AddrOpc ARM_AM_getAM5Op(unsigned AM5Opc)
static int getSOImmVal(unsigned Arg)
static unsigned getAM2Offset(unsigned AM2Opc)
static float getFPImmFloat(unsigned Imm)
static const char * ARMCC_ARMCondCodeToString(ARMCC_CondCodes CC)
static const char * ARM_PROC_IFlagsToString(unsigned val)
static const char * ARM_ISB_InstSyncBOptToString(unsigned val)
static const char * ARM_MB_MemBOptToString(unsigned val, bool HasV8)
static const char * ARM_PROC_IModToString(unsigned val)
uint64_t ARM_getFeatureBits(unsigned int mode)
void ARM_addVectorDataType(MCInst *MI, arm_vectordata_type vd)
void ARM_addSysReg(MCInst *MI, arm_sysreg reg)
void ARM_addVectorDataSize(MCInst *MI, int size)
void ARM_post_printer(csh handle, cs_insn *pub_insn, char *mnem, MCInst *mci)
void ARM_printInst(MCInst *MI, SStream *O, void *Info)
void ARM_getRegName(cs_struct *handle, int value)
void ARM_addReg(MCInst *MI, int reg)
void ARM_addUserMode(MCInst *MI)
const char * ARM_reg_name2(csh handle, unsigned int reg)
const char * ARM_reg_name(csh handle, unsigned int reg)
uint8_t * ARM_get_op_access(cs_struct *h, unsigned int id)
bool ARM_blx_to_arm_mode(cs_struct *h, unsigned int insn_id)
bool ARM_rel_branch(cs_struct *h, unsigned int insn_id)
unsigned MCInst_getOpcode(const MCInst *inst)
unsigned MCInst_getNumOperands(const MCInst *inst)
MCOperand * MCInst_getOperand(MCInst *inst, unsigned i)
bool MCOperand_isReg(const MCOperand *op)
void MCInst_Init(MCInst *inst)
void MCOperand_CreateReg0(MCInst *mcInst, unsigned Reg)
void MCInst_setOpcodePub(MCInst *inst, unsigned Op)
int64_t MCOperand_getImm(MCOperand *op)
unsigned MCOperand_getReg(const MCOperand *op)
getReg - Returns the register number.
void MCInst_addOperand2(MCInst *inst, MCOperand *Op)
void MCInst_setOpcode(MCInst *inst, unsigned Op)
bool MCOperand_isImm(const MCOperand *op)
unsigned MCRegisterInfo_getMatchingSuperReg(const MCRegisterInfo *RI, unsigned Reg, unsigned SubIdx, const MCRegisterClass *RC)
const MCRegisterClass * MCRegisterInfo_getRegClass(const MCRegisterInfo *RI, unsigned i)
bool MCRegisterClass_contains(const MCRegisterClass *c, unsigned Reg)
unsigned MCRegisterInfo_getSubReg(const MCRegisterInfo *RI, unsigned Reg, unsigned Idx)
void printUInt32Bang(SStream *O, uint32_t val)
void SStream_concat(SStream *ss, const char *fmt,...)
void printInt32Bang(SStream *O, int32_t val)
void SStream_concat0(SStream *ss, const char *s)
void printUInt32(SStream *O, uint32_t val)
void op_addImm(MCInst *MI, int v)
static mcore_handle handle
arm_shifter
ARM shift type.
@ ARM_SFT_ASR
shift with immediate const
@ ARM_SFT_ROR
shift with immediate const
@ ARM_SFT_LSL
shift with immediate const
@ ARM_SFT_ASR_REG
shift with register
@ ARM_SETEND_LE
LE operand.
@ ARM_SETEND_BE
BE operand.
@ ARM_SYSREG_EAPSR_NZCVQG
@ ARM_SYSREG_IAPSR_NZCVQG
@ ARM_OP_IMM
= CS_OP_IMM (Immediate operand).
@ ARM_OP_REG
= CS_OP_REG (Register operand).
@ ARM_OP_CIMM
C-Immediate (coprocessor registers)
@ ARM_OP_SETEND
operand for SETEND instruction
@ ARM_OP_PIMM
P-Immediate (coprocessor registers)
@ ARM_OP_MEM
= CS_OP_MEM (Memory operand).
@ ARM_OP_FP
= CS_OP_FP (Floating-Point operand).
@ ARM_OP_SYSREG
MSR/MRS special register operand.
@ ARM_CC_AL
Always (unconditional) Always (unconditional)
@ ARM_CPSFLAG_NONE
no flag
arm_vectordata_type
Data type for elements of vector instructions.
@ CS_MODE_THUMB
ARM's Thumb mode, including Thumb-2.
@ CS_OPT_SYNTAX_NOREGNAME
Prints register name with only number (CS_OPT_SYNTAX)
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
@ CS_AC_READ
Operand read from memory or register.
@ CS_AC_WRITE
Operand write to memory or register.
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
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
cs_opt_value imm_unsigned
if(dbg->bits==RZ_SYS_BITS_64)