Rizin
unix-like reverse engineering framework and cli tools
arm_accessors32.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2013-2021 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
10 #include <capstone/capstone.h>
11 
12 #define REGID(x) insn->detail->arm.operands[x].reg
13 #define IMM(x) (ut32)(insn->detail->arm.operands[x].imm)
14 #define INSOP(x) insn->detail->arm.operands[x]
15 #define REGBASE(x) insn->detail->arm.operands[x].mem.base
16 // s/index/base|reg/
17 #define HASMEMINDEX(x) (insn->detail->arm.operands[x].mem.index != ARM_REG_INVALID)
18 #define ISMEMINDEXSUB(x) insn->detail->arm.operands[x].subtracted
19 #define MEMDISP(x) insn->detail->arm.operands[x].mem.disp
20 #define ISIMM(x) (insn->detail->arm.operands[x].type == ARM_OP_IMM)
21 #define ISREG(x) (insn->detail->arm.operands[x].type == ARM_OP_REG)
22 #define ISMEM(x) (insn->detail->arm.operands[x].type == ARM_OP_MEM)
23 
24 #if CS_API_MAJOR > 3
25 #define LSHIFT(x) insn->detail->arm.operands[x].mem.lshift
26 #define LSHIFT2(x) insn->detail->arm.operands[x].shift.value // Dangerous, returns value even if isn't LSL
27 #else
28 #define LSHIFT(x) 0
29 #define LSHIFT2(x) 0
30 #endif
31 #define OPCOUNT() insn->detail->arm.op_count
32 #define ISSHIFTED(x) (insn->detail->arm.operands[x].shift.type != ARM_SFT_INVALID && insn->detail->arm.operands[x].shift.value != 0)
33 #define SHIFTTYPE(x) insn->detail->arm.operands[x].shift.type
34 #define SHIFTVALUE(x) insn->detail->arm.operands[x].shift.value
35 
36 #define ISWRITEBACK32() insn->detail->arm.writeback
37 #define ISPREINDEX32() (((OPCOUNT() == 2) && (ISMEM(1)) && (ISWRITEBACK32())) || ((OPCOUNT() == 3) && (ISMEM(2)) && (ISWRITEBACK32())))
38 #define ISPOSTINDEX32() (((OPCOUNT() == 3) && (ISIMM(2) || ISREG(2)) && (ISWRITEBACK32())) || ((OPCOUNT() == 4) && (ISIMM(3) || ISREG(3)) && (ISWRITEBACK32())))