1 /* Capstone testing regression */
2 /* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
3
4
5 #include "factory.h"
6
get_detail_sysz(csh * handle,cs_mode mode,cs_insn * ins)7 char *get_detail_sysz(csh *handle, cs_mode mode, cs_insn *ins)
8 {
9 cs_sysz *sysz;
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 sysz = &(ins->detail->sysz);
20 if (sysz->op_count)
21 add_str(&result, " ; op_count: %u", sysz->op_count);
22
23 for (i = 0; i < sysz->op_count; i++) {
24 cs_sysz_op *op = &(sysz->operands[i]);
25 switch((int)op->type) {
26 default:
27 break;
28 case SYSZ_OP_REG:
29 add_str(&result, " ; operands[%u].type: REG = %s", i, cs_reg_name(*handle, op->reg));
30 break;
31 case SYSZ_OP_ACREG:
32 add_str(&result, " ; operands[%u].type: ACREG = %u", i, op->reg);
33 break;
34 case SYSZ_OP_IMM:
35 add_str(&result, " ; operands[%u].type: IMM = 0x%" PRIx64 "", i, op->imm);
36 break;
37 case SYSZ_OP_MEM:
38 add_str(&result, " ; operands[%u].type: MEM", i);
39 if (op->mem.base != SYSZ_REG_INVALID)
40 add_str(&result, " ; operands[%u].mem.base: REG = %s", i, cs_reg_name(*handle, op->mem.base));
41 if (op->mem.index != SYSZ_REG_INVALID)
42 add_str(&result, " ; operands[%u].mem.index: REG = %s", i, cs_reg_name(*handle, op->mem.index));
43 if (op->mem.length != 0)
44 add_str(&result, " ; operands[%u].mem.length: 0x%" PRIx64 "", i, op->mem.length);
45 if (op->mem.disp != 0)
46 add_str(&result, " ; operands[%u].mem.disp: 0x%" PRIx64 "", i, op->mem.disp);
47
48 break;
49 }
50 }
51
52 if (sysz->cc != 0)
53 add_str(&result, " ; Code condition: %u", sysz->cc);
54
55 return result;
56 }
57
58