Debian Codegraph @

cstool/cstool_tricore.c

raw symbols SCIP
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include <capstone/capstone.h>
5 #include "cstool.h"
6
7 void print_insn_detail_tricore(csh handle, cs_insn *ins)
8 {
9 cs_tricore *tricore;
10 int i;
11 cs_regs regs_read, regs_write;
12 uint8_t regs_read_count, regs_write_count;
13
14 // detail can be NULL on "data" instruction if SKIPDATA option is turned ON
15 if (ins->detail == NULL)
16 return;
17
18 tricore = &(ins->detail->tricore);
19
20 if (tricore->op_count)
21 printf("\top_count: %u\n", tricore->op_count);
22
23 for (i = 0; i < tricore->op_count; i++) {
24 cs_tricore_op *op = &(tricore->operands[i]);
25 switch ((int)op->type) {
26 default:
27 break;
28 case TRICORE_OP_REG:
29 printf("\t\toperands[%u].type: REG = %s\n", i,
30 cs_reg_name(handle, op->reg));
31 break;
32 case TRICORE_OP_IMM:
33 printf("\t\toperands[%u].type: IMM = 0x%x\n", i,
34 op->imm);
35 break;
36 case TRICORE_OP_MEM:
37 printf("\t\toperands[%u].type: MEM\n"
38 "\t\t\t.mem.base: REG = %s\n"
39 "\t\t\t.mem.disp: 0x%x\n",
40 i, cs_reg_name(handle, op->mem.base),
41 op->mem.disp);
42 break;
43 }
44
45 switch (op->access) {
46 default:
47 break;
48 case CS_AC_READ:
49 printf("\t\t\t.access: READ\n");
50 break;
51 case CS_AC_WRITE:
52 printf("\t\t\t.access: WRITE\n");
53 break;
54 case CS_AC_READ | CS_AC_WRITE:
55 printf("\t\t\t.access: READ | WRITE\n");
56 break;
57 }
58 }
59 // Print out all registers accessed by this instruction (either implicit or
60 // explicit)
61 if (!cs_regs_access(handle, ins, regs_read, &regs_read_count,
62 regs_write, &regs_write_count)) {
63 if (regs_read_count) {
64 printf("\tRegisters read:");
65 for (i = 0; i < regs_read_count; i++) {
66 printf(" %s",
67 cs_reg_name(handle, regs_read[i]));
68 }
69 printf("\n");
70 }
71
72 if (regs_write_count) {
73 printf("\tRegisters modified:");
74 for (i = 0; i < regs_write_count; i++) {
75 printf(" %s",
76 cs_reg_name(handle, regs_write[i]));
77 }
78 printf("\n");
79 }
80 }
81
82 if (tricore->update_flags)
83 printf("\tUpdate-flags: True\n");
84 }