Debian Codegraph @

cstool/cstool_riscv.c

raw symbols SCIP
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_riscv(csh handle, cs_insn *ins)
9 {
10 cs_riscv *riscv;
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 riscv = &(ins->detail->riscv);
18 if (riscv->op_count)
19 printf("\top_count: %u\n", riscv->op_count);
20
21 for (i = 0; i < riscv->op_count; i++) {
22 cs_riscv_op *op = &(riscv->operands[i]);
23 switch((int)op->type) {
24 default:
25 break;
26 case RISCV_OP_REG:
27 printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
28 break;
29 case RISCV_OP_IMM:
30 printf("\t\toperands[%u].type: IMM = 0x%lx\n", i, (long)op->imm);
31 break;
32 case RISCV_OP_MEM:
33 printf("\t\toperands[%u].type: MEM\n", i);
34 if (op->mem.base != RISCV_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.disp != 0)
38 printf("\t\t\toperands[%u].mem.disp: 0x%lx\n", i, (long)op->mem.disp);
39
40 break;
41 }
42 }
43
44 printf("\n");
45 }