6 #include <capstone/capstone.h>
9 #define CAPSTONE_HAS_M68K 1
11 #define CAPSTONE_HAS_M68K 0
13 #pragma message("Cannot find capstone-m68k support")
15 #warning Cannot find capstone-m68k support
23 #define OPERAND(x) insn->detail->m68k.operands[x]
24 #define REG(x) cs_reg_name(*handle, insn->detail->m68k.operands[x].reg)
25 #define IMM(x) insn->detail->m68k.operands[x].imm
26 #define MEMBASE(x) cs_reg_name(*handle, insn->detail->m68k.operands[x].mem.base)
27 #define MEMINDEX(x) insn->detail->m68k.operands[x].mem.index
28 #define MEMDISP(x) insn->detail->m68k.operands[x].mem.disp
30 static inline ut64 make_64bits_address(
ut64 address) {
39 op->jump = make_64bits_address(
addr +
m68k->operands[index].br_disp.disp + 2);
40 op->fail = make_64bits_address(
addr +
op->size);
45 op->jump = make_64bits_address(
addr +
m68k->operands[index].br_disp.disp + 2);
46 op->fail = make_64bits_address(
addr +
op->size);
55 op->jump = make_64bits_address(
addr +
m68k->operands[0].mem.disp + 2);
57 op->jump = make_64bits_address(
m68k->operands[0].imm);
60 op->fail = make_64bits_address(
addr +
op->size);
71 pj_ka(pj,
"operands");
72 for (
i = 0;
i <
x->op_count;
i++) {
77 pj_ks(pj,
"type",
"reg");
81 pj_ks(pj,
"type",
"imm");
85 pj_ks(pj,
"type",
"mem");
95 pj_kN(pj,
"in_disp",
op->mem.in_disp);
96 pj_kN(pj,
"out_disp",
op->mem.out_disp);
97 pj_ki(pj,
"disp",
op->mem.disp);
98 pj_ki(pj,
"scale",
op->mem.scale);
99 pj_ki(pj,
"bitfield",
op->mem.bitfield);
100 pj_ki(pj,
"width",
op->mem.width);
101 pj_ki(pj,
"offset",
op->mem.offset);
102 pj_ki(pj,
"index_size",
op->mem.index_size);
105 pj_ks(pj,
"type",
"invalid");
145 op->src[0]->reg = &
reg;
170 int n, ret, opsize = -1;
172 static int omode = -1;
173 static int obits = 32;
181 if (
mode != omode ||
a->bits != obits) {
189 if (
a->cpu && strstr(
a->cpu,
"68000")) {
192 if (
a->cpu && strstr(
a->cpu,
"68010")) {
195 if (
a->cpu && strstr(
a->cpu,
"68020")) {
198 if (
a->cpu && strstr(
a->cpu,
"68030")) {
201 if (
a->cpu && strstr(
a->cpu,
"68040")) {
204 if (
a->cpu && strstr(
a->cpu,
"68060")) {
216 if (n < 1 || insn->
size < 1) {
231 opsize =
op->size = insn->size;
749 "gpr ccr .32 104 0\n"
750 "gpr sfc .32 108 0\n"
751 "gpr dfc .32 112 0\n"
752 "gpr usp .32 116 0\n"
753 "gpr vbr .32 120 0\n"
754 "gpr cacr .32 124 0\n"
755 "gpr caar .32 128 0\n"
756 "gpr msp .32 132 0\n"
757 "gpr isp .32 136 0\n"
759 "gpr itt0 .32 144 0\n"
760 "gpr itt1 .32 148 0\n"
761 "gpr dtt0 .32 156 0\n"
762 "gpr dtt1 .32 160 0\n"
763 "gpr mmusr .32 164 0\n"
764 "gpr urp .32 168 0\n"
765 "gpr srp .32 172 0\n"
766 "gpr fpcr .32 176 0\n"
767 "gpr fpsr .32 180 0\n"
768 "gpr fpiar .32 184 0\n";
774 .desc =
"Capstone M68K analyzer",
784 .
name =
"m68k (unsupported)",
785 .desc =
"Capstone M68K analyzer (unsupported)",
792 #ifndef RZ_PLUGIN_INCORE
RZ_API RzAnalysisValue * rz_analysis_value_new(void)
static int analop(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
static void op_fillval(RzAnalysis *analysis, RzAnalysisOp *op, csh handle, cs_insn *insn, int bits)
static void opex(RzStrBuf *buf, csh handle, cs_insn *insn)
static int parse_reg_name(RzReg *reg, RzRegItem **reg_base, RzRegItem **reg_delta, csh handle, cs_insn *insn, int reg_num)
RZ_API char * get_reg_profile(RzAnalysis *analysis)
RzAnalysisPlugin rz_analysis_plugin_m68k_cs
RZ_API RzLibStruct rizin_plugin
static mcore_handle handle
@ CS_ARCH_M68K
68K architecture
@ CS_MODE_M68K_040
M68K 68040 mode.
@ CS_MODE_M68K_000
M68K 68000 mode.
@ CS_MODE_M68K_060
M68K 68060 mode.
@ CS_MODE_M68K_010
M68K 68010 mode.
@ CS_MODE_BIG_ENDIAN
big-endian mode
@ CS_MODE_M68K_020
M68K 68020 mode.
@ CS_MODE_M68K_030
M68K 68030 mode.
@ CS_MODE_LITTLE_ENDIAN
little-endian mode (default mode)
@ CS_OPT_DETAIL
Break down instruction structure into details.
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
CAPSTONE_EXPORT size_t CAPSTONE_API cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, size_t count, cs_insn **insn)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle)
CAPSTONE_EXPORT void CAPSTONE_API cs_free(cs_insn *insn, size_t count)
CAPSTONE_EXPORT const char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_close(csh *handle)
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_option(csh ud, cs_opt_type type, size_t value)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
@ M68K_AM_PCI_DISP
Program Counter Indirect - with Displacement.
@ M68K_OP_BR_DISP
Branch displacement.
@ M68K_OP_IMM
= CS_OP_IMM (Immediate operand).
@ M68K_OP_REG
= CS_OP_REG (Register operand).
@ M68K_OP_MEM
= CS_OP_MEM (Memory operand).
@ RZ_ANALYSIS_OP_FAMILY_FPU
@ RZ_ANALYSIS_OP_MASK_VAL
@ RZ_ANALYSIS_OP_MASK_OPEX
#define RZ_ANALYSIS_OP_TYPE_MASK
@ RZ_ANALYSIS_OP_TYPE_CMP
@ RZ_ANALYSIS_OP_TYPE_SUB
@ RZ_ANALYSIS_OP_TYPE_UNK
@ RZ_ANALYSIS_OP_TYPE_MUL
@ RZ_ANALYSIS_OP_TYPE_ROL
@ RZ_ANALYSIS_OP_TYPE_JMP
@ RZ_ANALYSIS_OP_TYPE_AND
@ RZ_ANALYSIS_OP_TYPE_ROR
@ RZ_ANALYSIS_OP_TYPE_TRAP
@ RZ_ANALYSIS_OP_TYPE_CALL
@ RZ_ANALYSIS_OP_TYPE_ADD
@ RZ_ANALYSIS_OP_TYPE_PUSH
@ RZ_ANALYSIS_OP_TYPE_SHR
@ RZ_ANALYSIS_OP_TYPE_POP
@ RZ_ANALYSIS_OP_TYPE_CJMP
@ RZ_ANALYSIS_OP_TYPE_DIV
@ RZ_ANALYSIS_OP_TYPE_MOV
@ RZ_ANALYSIS_OP_TYPE_SHL
@ RZ_ANALYSIS_OP_TYPE_ILL
@ RZ_ANALYSIS_OP_TYPE_NOT
@ RZ_ANALYSIS_OP_TYPE_RET
@ RZ_ANALYSIS_OP_TYPE_NOP
@ RZ_ANALYSIS_OP_TYPE_LEA
@ RZ_ANALYSIS_OP_TYPE_XOR
RZ_API PJ * pj_ka(PJ *j, const char *k)
RZ_API PJ * pj_ki(PJ *j, const char *k, int d)
RZ_API PJ * pj_end(PJ *j)
RZ_API const char * pj_string(PJ *pj)
RZ_API void pj_free(PJ *j)
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
RZ_API PJ * pj_kN(PJ *j, const char *k, st64 n)
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
RZ_API void rz_strbuf_init(RzStrBuf *sb)
The M68K instruction and it's operands.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()