Debian Codegraph @

cstool/cstool_powerpc.c

raw symbols SCIP
1 /* Capstone Disassembler Engine */cxx . . $ `<file>/cstool/cstool_powerpc.c`/
2 /* By Nguyen Anh Quynh <[email protected]>, 2013> */
3
4 #include <stdio.h>
5
6 #include <capstone/capstone.h>cxx . . $ `<file>/include/capstone/capstone.h`/
7 #include "cstool.h"cxx . . $ `<file>/cstool/cstool.h`/
8
9 static const char* get_bc_namecxx . . $ get_bc_name(f7ae7e56280f18ae).(int bc)
10 {
11 switch(bc) {
12 default:
13 case PPC_BC_INVALIDcxx . . $ PPC_BC_INVALID.:
14 return ("invalid");
15 case PPC_BC_LTcxx . . $ PPC_BC_LT.:
16 return ("lt");
17 case PPC_BC_LEcxx . . $ PPC_BC_LE.:
18 return ("le");
19 case PPC_BC_EQcxx . . $ PPC_BC_EQ.:
20 return ("eq");
21 case PPC_BC_GEcxx . . $ PPC_BC_GE.:
22 return ("ge");
23 case PPC_BC_GTcxx . . $ PPC_BC_GT.:
24 return ("gt");
25 case PPC_BC_NEcxx . . $ PPC_BC_NE.:
26 return ("ne");
27 case PPC_BC_UNcxx . . $ PPC_BC_UN.:
28 return ("un");
29 case PPC_BC_NUcxx . . $ PPC_BC_NU.:
30 return ("nu");
31 case PPC_BC_SOcxx . . $ PPC_BC_SO.:
32 return ("so");
33 case PPC_BC_NScxx . . $ PPC_BC_NS.:
34 return ("ns");
35 }
36 }
37
38 void print_insn_detail_ppccxx . . $ print_insn_detail_ppc(2888c3e5b0984e8d).(cshcxx . . $ csh# handle, cs_insncxx . . $ cs_insn# *ins)
39 {
40 cs_ppccxx . . $ cs_ppc# *ppc;
41 int i;
42
43 // detail can be NULL on "data" instruction if SKIPDATA option is turned ON
44 if (ins->detailcxx . . $ cs_insn#detail. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
45 return;
46
47 ppc = &(ins->detailcxx . . $ cs_insn#detail.->ppccxx . . $ cs_detail#$anonymous_type_0#ppc.);
48 if (ppc->op_countcxx . . $ cs_ppc#op_count.)
49 printfcxx . . $ printf(581fddd72a8db8fc).("\top_count: %u\n", ppc->op_countcxx . . $ cs_ppc#op_count.);
50
51 for (i = 0; i < ppc->op_countcxx . . $ cs_ppc#op_count.; i++) {
52 cs_ppc_opcxx . . $ cs_ppc_op# *op = &(ppc->operandscxx . . $ cs_ppc#operands.[i]);
53 switch((int)op->typecxx . . $ cs_ppc_op#type.) {
54 default:
55 break;
56 case PPC_OP_REGcxx . . $ PPC_OP_REG.:
57 printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: REG = %s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->regcxx . . $ cs_ppc_op#$anonymous_type_0#reg.));
58 break;
59 case PPC_OP_IMMcxx . . $ PPC_OP_IMM.:
60 printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: IMM = 0x%"PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:126:10`!"\n", i, op->immcxx . . $ cs_ppc_op#$anonymous_type_0#imm.);
61 break;
62 case PPC_OP_MEMcxx . . $ PPC_OP_MEM.:
63 printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: MEM\n", i);
64 if (op->memcxx . . $ cs_ppc_op#$anonymous_type_0#mem..basecxx . . $ ppc_op_mem#base. != PPC_REG_INVALIDcxx . . $ PPC_REG_INVALID.)
65 printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.base: REG = %s\n",
66 i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->memcxx . . $ cs_ppc_op#$anonymous_type_0#mem..basecxx . . $ ppc_op_mem#base.));
67 if (op->memcxx . . $ cs_ppc_op#$anonymous_type_0#mem..dispcxx . . $ ppc_op_mem#disp. != 0)
68 printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.disp: 0x%x\n", i, op->memcxx . . $ cs_ppc_op#$anonymous_type_0#mem..dispcxx . . $ ppc_op_mem#disp.);
69
70 break;
71 case PPC_OP_CRXcxx . . $ PPC_OP_CRX.:
72 printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: CRX\n", i);
73 printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].crx.scale: %d\n", i, op->crxcxx . . $ cs_ppc_op#$anonymous_type_0#crx..scalecxx . . $ ppc_op_crx#scale.);
74 printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].crx.reg: %s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->crxcxx . . $ cs_ppc_op#$anonymous_type_0#crx..regcxx . . $ ppc_op_crx#reg.));
75 printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].crx.cond: %s\n", i, get_bc_namecxx . . $ get_bc_name(f7ae7e56280f18ae).(op->crxcxx . . $ cs_ppc_op#$anonymous_type_0#crx..condcxx . . $ ppc_op_crx#cond.));
76 break;
77 }
78 }
79
80 if (ppc->bccxx . . $ cs_ppc#bc. != 0)
81 printfcxx . . $ printf(581fddd72a8db8fc).("\tBranch code: %u\n", ppc->bccxx . . $ cs_ppc#bc.);
82
83 if (ppc->bhcxx . . $ cs_ppc#bh. != 0)
84 printfcxx . . $ printf(581fddd72a8db8fc).("\tBranch hint: %u\n", ppc->bhcxx . . $ cs_ppc#bh.);
85
86 if (ppc->update_cr0cxx . . $ cs_ppc#update_cr0.)
87 printfcxx . . $ printf(581fddd72a8db8fc).("\tUpdate-CR0: True\n");
88 }