7 #include <capstone/platform.h>
8 #include <capstone/capstone.h>
10 #define ARR_SIZE(a) (sizeof(a)/sizeof(a[0]))
43 "UNCHANGED",
"READ",
"WRITE",
"READ | WRITE",
50 if (
detail->regs_read_count > 0) {
51 printf(
"\tRegisters read:");
53 for (
i = 0;
i <
detail->regs_read_count; ++
i)
60 if (
detail->regs_write_count > 0) {
61 printf(
"\tRegisters modified:");
63 for (
i = 0;
i <
detail->regs_write_count; ++
i)
73 cs_detail *
detail = insn->detail;
90 switch ((
int)
op->type) {
97 if ((
i == 0 && (m680x->
flags &
99 ((
i == 1 && (m680x->
flags &
101 comment =
" (in mnemonic)";
103 printf(
"\t\toperands[%u].type: REGISTER = %s%s\n",
i,
108 printf(
"\t\toperands[%u].type: CONSTANT = %u\n",
i,
113 printf(
"\t\toperands[%u].type: IMMEDIATE = #%d\n",
i,
118 printf(
"\t\toperands[%u].type: DIRECT = 0x%02x\n",
i,
123 printf(
"\t\toperands[%u].type: EXTENDED %s = 0x%04x\n",
124 i,
op->ext.indirect ?
"INDIRECT" :
"",
129 printf(
"\t\toperands[%u].type: RELATIVE = 0x%04x\n",
i,
134 printf(
"\t\toperands[%u].type: INDEXED%s\n",
i,
139 printf(
"\t\t\tbase register: %s\n",
143 printf(
"\t\t\toffset register: %s\n",
146 if ((
op->idx.offset_bits != 0) &&
149 printf(
"\t\t\toffset: %d\n",
op->idx.offset);
152 printf(
"\t\t\toffset address: 0x%x\n",
153 op->idx.offset_addr);
155 printf(
"\t\t\toffset bits: %u\n",
156 op->idx.offset_bits);
159 if (
op->idx.inc_dec) {
160 const char *post_pre =
op->idx.flags &
162 const char *inc_dec = (
op->idx.inc_dec > 0) ?
163 "increment" :
"decrement";
165 printf(
"\t\t\t%s %s: %d\n", post_pre, inc_dec,
166 abs(
op->idx.inc_dec));
173 printf(
"\t\t\tsize: %u\n",
op->size);
182 if (
detail->groups_count) {
197 "\x01\x09\x36\x64\x7f\x74\x10\x00\x90\x10\xA4\x10\xb6\x10\x00\x39"
200 "\x04\x05\x3c\x3d\x38\x93\x10\xec\x10\xed\x10\x39"
203 "\x04\x7f\x00\x17\x22\x28\x00\x2e\x00\x40\x42\x5a\x70\x8e\x97\x9c" \
204 "\xa0\x15\xad\x00\xc3\x10\x00\xda\x12\x34\xe5\x7f\xfe"
207 "\x31\x22\x00\x35\x22\x45\x10\x00\x4b\x00\x51\x10\x52\x5e\x22\x62" \
208 "\x65\x12\x34\x72\x84\x85\x86\x87\x8a\x8b\x8c\x94\x95\xa7\x10\xaf\x10" \
209 "\x9e\x60\x7f\x9e\x6b\x7f\x00\x9e\xd6\x10\x00\x9e\xe6\x7f"
212 "\x32\x10\x00\x9e\xae\x9e\xce\x7f\x9e\xbe\x10\x00\x9e\xfe\x7f" \
213 "\x3e\x10\x00\x9e\xf3\x7f\x96\x10\x00\x9e\xff\x7f\x82"
216 "\x02\x03\x12\x7f\x10\x00\x13\x99\x08\x00\x14\x7f\x02\x15\x7f\x01" \
217 "\x1e\x7f\x20\x00\x8f\xcf" \
218 "\x18\x08\x18\x30\x18\x3c\x18\x67\x18\x8c\x10\x00\x18\x8f" \
219 "\x18\xce\x10\x00\x18\xff\x10\x00" \
220 "\x1a\xa3\x7f\x1a\xac\x1a\xee\x7f\x1a\xef\x7f\xcd\xac\x7f"
223 "\x00\x04\x01\x00\x0c\x00\x80\x0e\x00\x80\x00\x11\x1e\x10\x00\x80\x00" \
224 "\x3b\x4a\x10\x00\x04\x4b\x01\x04\x4f\x7f\x80\x00\x8f\x10\x00\xb7\x52" \
225 "\xb7\xb1\xa6\x67\xa6\xfe\xa6\xf7\x18\x02\xe2\x30\x39\xe2\x10\x00" \
226 "\x18\x0c\x30\x39\x10\x00\x18\x11\x18\x12\x10\x00\x18\x19\x00\x18\x1e\x00" \
227 "\x18\x3e\x18\x3f\x00"
229 #define HD6301_CODE \
230 "\x6b\x10\x00\x71\x10\x00\x72\x10\x10\x39"
233 "\x06\x10\x19\x1a\x55\x1e\x01\x23\xe9\x31\x06\x34\x55\xa6\x81" \
234 "\xa7\x89\x7f\xff\xa6\x9d\x10\x00\xa7\x91\xa6\x9f\x10\x00" \
235 "\x11\xac\x99\x10\x00\x39" \
237 "\xA6\x07\xA6\x27\xA6\x47\xA6\x67\xA6\x0F\xA6\x10" \
238 "\xA6\x80\xA6\x81\xA6\x82\xA6\x83\xA6\x84\xA6\x85\xA6\x86" \
239 "\xA6\x88\x7F\xA6\x88\x80\xA6\x89\x7F\xFF\xA6\x89\x80\x00" \
240 "\xA6\x8B\xA6\x8C\x10\xA6\x8D\x10\x00" \
242 "\xA6\x91\xA6\x93\xA6\x94\xA6\x95\xA6\x96" \
243 "\xA6\x98\x7F\xA6\x98\x80\xA6\x99\x7F\xFF\xA6\x99\x80\x00" \
244 "\xA6\x9B\xA6\x9C\x10\xA6\x9D\x10\x00\xA6\x9F\x10\x00"
247 #define HD6309_CODE \
248 "\x01\x10\x10\x62\x10\x10\x7b\x10\x10\x00\xcd\x49\x96\x02\xd2" \
249 "\x10\x30\x23\x10\x38\x10\x3b\x10\x53\x10\x5d" \
250 "\x11\x30\x43\x10\x11\x37\x25\x10\x11\x38\x12\x11\x39\x23\x11\x3b\x34" \
251 "\x11\x8e\x10\x00\x11\xaf\x10\x11\xab\x10\x11\xf6\x80\x00"
331 const char *nine_spaces =
" ";
341 printf(
"Failed on cs_open() with error returned: %u\n",
356 printf(
"********************\n");
362 for (j = 0; j <
count; j++) {
371 printf(
"%.*s", 1 + (5 - slen), nine_spaces);
372 printf(
"%s\n", insn[j].op_str);
382 printf(
"********************\n");
386 printf(
"ERROR: Failed to disasm given code!\n");
static mcore_handle handle
cs_arch
Architecture type.
@ CS_ARCH_M680X
680X architecture
@ CS_MODE_M680X_6811
M680X Motorola/Freescale/NXP 68HC11 mode.
@ CS_MODE_M680X_6805
M680X Motorola/Freescale 6805 mode.
@ CS_MODE_M680X_HCS08
M680X Freescale/NXP HCS08 mode.
@ CS_MODE_M680X_6309
M680X Hitachi 6309 mode.
@ CS_MODE_M680X_CPU12
used on M68HC12/HCS12
@ CS_MODE_M680X_6301
M680X Hitachi 6301,6303 mode.
@ CS_MODE_M680X_6801
M680X Motorola 6801,6803 mode.
@ CS_MODE_M680X_6800
M680X Motorola 6800,6802 mode.
@ CS_MODE_M680X_6808
M680X Motorola/Freescale/NXP 68HC08 mode.
@ CS_MODE_M680X_6809
M680X Motorola 6809 mode.
@ CS_OPT_DETAIL
Break down instruction structure into details.
@ CS_OPT_ON
Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA).
@ CS_AC_INVALID
Uninitialized/invalid access type.
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[]
#define M680X_IDX_INDIRECT
#define M680X_FIRST_OP_IN_MNEM
@ M680X_REG_PC
M6800/1/2/3/9, M6301/9.
#define M680X_IDX_POST_INC_DEC
@ M680X_OP_EXTENDED
= Extended addressing operand.
@ M680X_OP_INDEXED
= Indexed addressing operand.
@ M680X_OP_CONSTANT
Used e.g. for a bit index or page number.
@ M680X_OP_IMMEDIATE
= Immediate operand.
@ M680X_OP_REGISTER
= Register operand.
@ M680X_OP_RELATIVE
= Relative addressing operand.
@ M680X_OP_DIRECT
= Direct addressing operand.
#define M680X_SECOND_OP_IN_MNEM
The M680X instruction and it's operands.
uint8_t flags
See: M680X instruction flags.
cs_m680x_op operands[M680X_OPERAND_COUNT]
operands for this insn.
uint8_t op_count
number of operands for the instruction or 0
static void print_insn_detail(csh handle, cs_insn *insn)
static const char * s_access[]
static bool consistency_checks()
static void print_string_hex(const char *comment, unsigned char *str, size_t len)
static void print_string_hex_short(unsigned char *str, size_t len)
static void print_read_write_regs(csh handle, cs_detail *detail)