static void print_insn_detail(csh handle, cs_insn *insn) { cs_detail *detail = insn->detail; cs_m680x *m680x = NULL; int i; // detail can be NULL on "data" instruction if SKIPDATA option is turned ON if (detail == NULL) return; m680x = &detail->m680x; if (m680x->op_count) printf("\top_count: %u\n", m680x->op_count); for (i = 0; i < m680x->op_count; i++) { cs_m680x_op *op = &(m680x->operands[i]); const char *comment; switch ((int)op->type) { default: break; case M680X_OP_REGISTER: comment = ""; if ((i == 0 && (m680x->flags & M680X_FIRST_OP_IN_MNEM)) || ((i == 1 && (m680x->flags & M680X_SECOND_OP_IN_MNEM)))) comment = " (in mnemonic)"; printf("\t\toperands[%u].type: REGISTER = %s%s\n", i, cs_reg_name(handle, op->reg), comment); break; case M680X_OP_CONSTANT: printf("\t\toperands[%u].type: CONSTANT = %u\n", i, op->const_val); break; case M680X_OP_IMMEDIATE: printf("\t\toperands[%u].type: IMMEDIATE = #%d\n", i, op->imm); break; case M680X_OP_DIRECT: printf("\t\toperands[%u].type: DIRECT = 0x%02x\n", i, op->direct_addr); break; case M680X_OP_EXTENDED: printf("\t\toperands[%u].type: EXTENDED %s = 0x%04x\n", i, op->ext.indirect ? "INDIRECT" : "", op->ext.address); break; case M680X_OP_RELATIVE: printf("\t\toperands[%u].type: RELATIVE = 0x%04x\n", i, op->rel.address); break; case M680X_OP_INDEXED: printf("\t\toperands[%u].type: INDEXED%s\n", i, (op->idx.flags & M680X_IDX_INDIRECT) ? " INDIRECT" : ""); if (op->idx.base_reg != M680X_REG_INVALID) printf("\t\t\tbase register: %s\n", cs_reg_name(handle, op->idx.base_reg)); if (op->idx.offset_reg != M680X_REG_INVALID) printf("\t\t\toffset register: %s\n", cs_reg_name(handle, op->idx.offset_reg)); if ((op->idx.offset_bits != 0) && (op->idx.offset_reg == M680X_REG_INVALID) && !op->idx.inc_dec) { printf("\t\t\toffset: %d\n", op->idx.offset); if (op->idx.base_reg == M680X_REG_PC) printf("\t\t\toffset address: 0x%x\n", op->idx.offset_addr); printf("\t\t\toffset bits: %u\n", op->idx.offset_bits); } if (op->idx.inc_dec) { const char *post_pre = op->idx.flags & M680X_IDX_POST_INC_DEC ? "post" : "pre"; const char *inc_dec = (op->idx.inc_dec > 0) ? "increment" : "decrement"; printf("\t\t\t%s %s: %d\n", post_pre, inc_dec, abs(op->idx.inc_dec)); } break; } if (op->size != 0) printf("\t\t\tsize: %u\n", op->size); if (op->access != CS_AC_INVALID) printf("\t\t\taccess: %s\n", s_access[op->access]); } print_read_write_regs(handle, detail); if (detail->groups_count) { printf("\tgroups_count: %u\n", detail->groups_count); } printf("\n"); }
static void print_insn_detail(cs_insn *ins) { cs_m68k* m68k; cs_detail* detail; int i; // detail can be NULL on "data" instruction if SKIPDATA option is turned ON if (ins->detail == NULL) return; detail = ins->detail; m68k = &detail->m68k; if (m68k->op_count) printf("\top_count: %u\n", m68k->op_count); print_read_write_regs(detail); printf("\tgroups_count: %u\n", detail->groups_count); for (i = 0; i < m68k->op_count; i++) { cs_m68k_op* op = &(m68k->operands[i]); switch((int)op->type) { default: break; case M68K_OP_REG: printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg)); break; case M68K_OP_IMM: printf("\t\toperands[%u].type: IMM = 0x%x\n", i, (int)op->imm); break; case M68K_OP_MEM: printf("\t\toperands[%u].type: MEM\n", i); if (op->mem.base_reg != M68K_REG_INVALID) printf("\t\t\toperands[%u].mem.base: REG = %s\n", i, cs_reg_name(handle, op->mem.base_reg)); if (op->mem.index_reg != M68K_REG_INVALID) { printf("\t\t\toperands[%u].mem.index: REG = %s\n", i, cs_reg_name(handle, op->mem.index_reg)); printf("\t\t\toperands[%u].mem.index: size = %c\n", i, op->mem.index_size ? 'l' : 'w'); } if (op->mem.disp != 0) printf("\t\t\toperands[%u].mem.disp: 0x%x\n", i, op->mem.disp); if (op->mem.scale != 0) printf("\t\t\toperands[%u].mem.scale: %d\n", i, op->mem.scale); printf("\t\taddress mode: %s\n", s_addressing_modes[op->address_mode]); break; case M68K_OP_FP_SINGLE: printf("\t\toperands[%u].type: FP_SINGLE\n", i); printf("\t\t\toperands[%u].simm: %f\n", i, op->simm); break; case M68K_OP_FP_DOUBLE: printf("\t\toperands[%u].type: FP_DOUBLE\n", i); printf("\t\t\toperands[%u].dimm: %lf\n", i, op->dimm); break; case M68K_OP_REG_BITS: printf("\t\toperands[%u].type: REG_BITS = $%x\n", i, op->register_bits); } } printf("\n"); }