6 #include <capstone/platform.h>
7 #include <capstone/capstone.h>
34 "Register Direct - Data",
35 "Register Direct - Address",
37 "Register Indirect - Address",
38 "Register Indirect - Address with Postincrement",
39 "Register Indirect - Address with Predecrement",
40 "Register Indirect - Address with Displacement",
42 "Address Register Indirect With Index - 8-bit displacement",
43 "Address Register Indirect With Index - Base displacement",
45 "Memory indirect - Postindex",
46 "Memory indirect - Preindex",
48 "Program Counter Indirect - with Displacement",
50 "Program Counter Indirect with Index - with 8-Bit Displacement",
51 "Program Counter Indirect with Index - with Base Displacement",
53 "Program Counter Memory Indirect - Postindexed",
54 "Program Counter Memory Indirect - Preindexed",
56 "Absolute Data Addressing - Short",
57 "Absolute Data Addressing - Long",
65 for (
i = 0;
i <
detail->regs_read_count; ++
i)
69 printf(
"\treading from reg: %s\n", reg_name);
72 for (
i = 0;
i <
detail->regs_write_count; ++
i)
76 printf(
"\twriting to reg: %s\n", reg_name);
87 if (ins->detail ==
NULL)
99 for (
i = 0;
i <
m68k->op_count;
i++) {
102 switch((
int)
op->type) {
109 printf(
"\t\toperands[%u].type: IMM = 0x%x\n",
i, (
int)
op->imm);
112 printf(
"\t\toperands[%u].type: MEM\n",
i);
114 printf(
"\t\t\toperands[%u].mem.base: REG = %s\n",
117 printf(
"\t\t\toperands[%u].mem.index: REG = %s\n",
119 printf(
"\t\t\toperands[%u].mem.index: size = %c\n",
120 i,
op->mem.index_size ?
'l' :
'w');
122 if (
op->mem.disp != 0)
123 printf(
"\t\t\toperands[%u].mem.disp: 0x%x\n",
i,
op->mem.disp);
124 if (
op->mem.scale != 0)
125 printf(
"\t\t\toperands[%u].mem.scale: %d\n",
i,
op->mem.scale);
130 printf(
"\t\toperands[%u].type: FP_SINGLE\n",
i);
131 printf(
"\t\t\toperands[%u].simm: %f\n",
i,
op->simm);
134 printf(
"\t\toperands[%u].type: FP_DOUBLE\n",
i);
135 printf(
"\t\t\toperands[%u].dimm: %lf\n",
i,
op->dimm);
138 printf(
"\t\toperands[%u].type: REG_BITS = $%x\n",
i,
op->register_bits);
141 printf(
"\t\toperands[%u].type: REG_PAIR = (%s, %s)\n",
i,
153 #define M68K_CODE "\x4C\x00\x54\x04\x48\xe7\xe0\x30\x4C\xDF\x0C\x07\xd4\x40\x87\x5a\x4e\x71\x02\xb4\xc0\xde\xc0\xde\x5c\x00\x1d\x80\x71\x12\x01\x23\xf2\x3c\x44\x22\x40\x49\x0e\x56\x54\xc5\xf2\x3c\x44\x00\x44\x7a\x00\x00\xf2\x00\x0a\x28\x4E\xB9\x00\x00\x00\x12\x4E\x75"
172 printf(
"Failed on cs_open() with error returned: %u\n",
err);
182 printf(
"****************\n");
187 for (j = 0; j <
count; j++) {
196 printf(
"****************\n");
199 printf(
"ERROR: Failed to disasm given code!\n");
cs_arch
Architecture type.
@ CS_ARCH_M68K
68K architecture
@ CS_MODE_M68K_040
M68K 68040 mode.
@ CS_MODE_BIG_ENDIAN
big-endian 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)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
struct platform platforms[]
@ M68K_OP_REG_PAIR
Register pair in the same op (upper 4 bits for first reg, lower for second)
@ M68K_OP_IMM
= CS_OP_IMM (Immediate operand).
@ M68K_OP_FP_SINGLE
single precision Floating-Point operand
@ M68K_OP_FP_DOUBLE
double precision Floating-Point operand
@ M68K_OP_REG_BITS
Register bits move.
@ M68K_OP_REG
= CS_OP_REG (Register operand).
@ M68K_OP_MEM
= CS_OP_MEM (Memory operand).
The M68K instruction and it's operands.
static void print_read_write_regs(cs_detail *detail)
const char * s_addressing_modes[]
static void print_string_hex(const char *comment, unsigned char *str, size_t len)
static void print_insn_detail(cs_insn *ins)