1 /* Capstone testing regression */
2 /* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
3
4
5 #include "factory.h"
6
get_detail_xcore(csh * handle,cs_mode mode,cs_insn * ins)7 char *get_detail_xcore(csh *handle, cs_mode mode, cs_insn *ins)
8 {
9 cs_xcore *xcore;
10 int i;
11 char *result;
12
13 result = (char *)malloc(sizeof(char));
14 result[0] = '\0';
15
16 if (ins->detail == NULL)
17 return result;
18
19 xcore = &(ins->detail->xcore);
20 if (xcore->op_count)
21 add_str(&result, " ; op_count: %u", xcore->op_count);
22
23 for (i = 0; i < xcore->op_count; i++) {
24 cs_xcore_op *op = &(xcore->operands[i]);
25 switch((int)op->type) {
26 default:
27 break;
28 case XCORE_OP_REG:
29 add_str(&result, " ; operands[%u].type: REG = %s", i, cs_reg_name(*handle, op->reg));
30 break;
31 case XCORE_OP_IMM:
32 add_str(&result, " ; operands[%u].type: IMM = 0x%x", i, op->imm);
33 break;
34 case XCORE_OP_MEM:
35 add_str(&result, " ; operands[%u].type: MEM", i);
36 if (op->mem.base != XCORE_REG_INVALID)
37 add_str(&result, " ; operands[%u].mem.base: REG = %s", i, cs_reg_name(*handle, op->mem.base));
38 if (op->mem.index != XCORE_REG_INVALID)
39 add_str(&result, " ; operands[%u].mem.index: REG = %s", i, cs_reg_name(*handle, op->mem.index));
40 if (op->mem.disp != 0)
41 add_str(&result, " ; operands[%u].mem.disp: 0x%x", i, op->mem.disp);
42 if (op->mem.direct != 1)
43 add_str(&result, " ; operands[%u].mem.direct: -1", i);
44
45
46 break;
47 }
48 }
49
50 return result;
51 }
52
53