| 1 | /* Capstone Disassembler Engine */ |
| 2 | /* By Nguyen Anh Quynh <[email protected]>, 2013-2014 */ |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <capstone/capstone.h> |
| 6 | #include "cstool.h" |
| 7 | |
| 8 | void print_insn_detail_xcore(csh handle, cs_insn *ins) |
| 9 | { |
| 10 | cs_xcore *xcore; |
| 11 | int i; |
| 12 | |
| 13 | // detail can be NULL on "data" instruction if SKIPDATA option is turned ON |
| 14 | if (ins->detail == NULL) |
| 15 | return; |
| 16 | |
| 17 | xcore = &(ins->detail->xcore); |
| 18 | if (xcore->op_count) |
| 19 | printf("\top_count: %u\n", xcore->op_count); |
| 20 | |
| 21 | for (i = 0; i < xcore->op_count; i++) { |
| 22 | cs_xcore_op *op = &(xcore->operands[i]); |
| 23 | switch((int)op->type) { |
| 24 | default: |
| 25 | break; |
| 26 | case XCORE_OP_REG: |
| 27 | printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg)); |
| 28 | break; |
| 29 | case XCORE_OP_IMM: |
| 30 | printf("\t\toperands[%u].type: IMM = 0x%x\n", i, op->imm); |
| 31 | break; |
| 32 | case XCORE_OP_MEM: |
| 33 | printf("\t\toperands[%u].type: MEM\n", i); |
| 34 | if (op->mem.base != XCORE_REG_INVALID) |
| 35 | printf("\t\t\toperands[%u].mem.base: REG = %s\n", |
| 36 | i, cs_reg_name(handle, op->mem.base)); |
| 37 | if (op->mem.index != XCORE_REG_INVALID) |
| 38 | printf("\t\t\toperands[%u].mem.index: REG = %s\n", |
| 39 | i, cs_reg_name(handle, op->mem.index)); |
| 40 | if (op->mem.disp != 0) |
| 41 | printf("\t\t\toperands[%u].mem.disp: 0x%x\n", i, op->mem.disp); |
| 42 | if (op->mem.direct != 1) |
| 43 | printf("\t\t\toperands[%u].mem.direct: -1\n", i); |
| 44 | |
| 45 | |
| 46 | break; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | printf("\n"); |
| 51 | } |