Rizin
unix-like reverse engineering framework and cli tools
cstool_ppc.c File Reference
#include <stdio.h>
#include <capstone/capstone.h>

Go to the source code of this file.

Functions

void print_string_hex (char *comment, unsigned char *str, size_t len)
 
static const char * get_bc_name (int bc)
 
void print_insn_detail_ppc (csh handle, cs_insn *ins)
 

Function Documentation

◆ get_bc_name()

static const char* get_bc_name ( int  bc)
static

Definition at line 10 of file cstool_ppc.c.

11 {
12  switch(bc) {
13  default:
14  case PPC_BC_INVALID:
15  return ("invalid");
16  case PPC_BC_LT:
17  return ("lt");
18  case PPC_BC_LE:
19  return ("le");
20  case PPC_BC_EQ:
21  return ("eq");
22  case PPC_BC_GE:
23  return ("ge");
24  case PPC_BC_GT:
25  return ("gt");
26  case PPC_BC_NE:
27  return ("ne");
28  case PPC_BC_UN:
29  return ("un");
30  case PPC_BC_NU:
31  return ("nu");
32  case PPC_BC_SO:
33  return ("so");
34  case PPC_BC_NS:
35  return ("ns");
36  }
37 }
@ PPC_BC_LE
Definition: ppc.h:21
@ PPC_BC_EQ
Definition: ppc.h:22
@ PPC_BC_SO
summary overflow
Definition: ppc.h:30
@ PPC_BC_UN
Definition: ppc.h:26
@ PPC_BC_NE
Definition: ppc.h:25
@ PPC_BC_GT
Definition: ppc.h:24
@ PPC_BC_NU
Definition: ppc.h:27
@ PPC_BC_NS
not summary overflow
Definition: ppc.h:31
@ PPC_BC_LT
Definition: ppc.h:20
@ PPC_BC_INVALID
Definition: ppc.h:19
@ PPC_BC_GE
Definition: ppc.h:23

References PPC_BC_EQ, PPC_BC_GE, PPC_BC_GT, PPC_BC_INVALID, PPC_BC_LE, PPC_BC_LT, PPC_BC_NE, PPC_BC_NS, PPC_BC_NU, PPC_BC_SO, and PPC_BC_UN.

Referenced by print_insn_detail_ppc().

◆ print_insn_detail_ppc()

void print_insn_detail_ppc ( csh  handle,
cs_insn *  ins 
)

Definition at line 39 of file cstool_ppc.c.

40 {
41  cs_ppc *ppc;
42  int i;
43 
44  // detail can be NULL on "data" instruction if SKIPDATA option is turned ON
45  if (ins->detail == NULL)
46  return;
47 
48  ppc = &(ins->detail->ppc);
49  if (ppc->op_count)
50  printf("\top_count: %u\n", ppc->op_count);
51 
52  for (i = 0; i < ppc->op_count; i++) {
53  cs_ppc_op *op = &(ppc->operands[i]);
54  switch((int)op->type) {
55  default:
56  break;
57  case PPC_OP_REG:
58  printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
59  break;
60  case PPC_OP_IMM:
61  printf("\t\toperands[%u].type: IMM = 0x%"PRIx64"\n", i, op->imm);
62  break;
63  case PPC_OP_MEM:
64  printf("\t\toperands[%u].type: MEM\n", i);
65  if (op->mem.base != PPC_REG_INVALID)
66  printf("\t\t\toperands[%u].mem.base: REG = %s\n",
67  i, cs_reg_name(handle, op->mem.base));
68  if (op->mem.disp != 0)
69  printf("\t\t\toperands[%u].mem.disp: 0x%x\n", i, op->mem.disp);
70 
71  break;
72  case PPC_OP_CRX:
73  printf("\t\toperands[%u].type: CRX\n", i);
74  printf("\t\t\toperands[%u].crx.scale: %d\n", i, op->crx.scale);
75  printf("\t\t\toperands[%u].crx.reg: %s\n", i, cs_reg_name(handle, op->crx.reg));
76  printf("\t\t\toperands[%u].crx.cond: %s\n", i, get_bc_name(op->crx.cond));
77  break;
78  }
79  }
80 
81  if (ppc->bc != 0)
82  printf("\tBranch code: %u\n", ppc->bc);
83 
84  if (ppc->bh != 0)
85  printf("\tBranch hint: %u\n", ppc->bh);
86 
87  if (ppc->update_cr0)
88  printf("\tUpdate-CR0: True\n");
89 }
lzma_index ** i
Definition: index.h:629
static mcore_handle handle
Definition: asm_mcore.c:8
#define NULL
Definition: cris-opc.c:27
CAPSTONE_EXPORT const char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
Definition: cs.c:1154
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
static const char * get_bc_name(int bc)
Definition: cstool_ppc.c:10
Instruction operand.
Definition: ppc.h:283
Instruction structure.
Definition: ppc.h:294
@ PPC_OP_REG
= CS_OP_REG (Register operand).
Definition: ppc.h:44
@ PPC_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: ppc.h:45
@ PPC_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: ppc.h:46
@ PPC_OP_CRX
Condition Register field.
Definition: ppc.h:47
@ PPC_REG_INVALID
Definition: ppc.h:52
#define PRIx64
Definition: sysdefs.h:94
Definition: dis.c:32

References cs_reg_name(), get_bc_name(), handle, i, NULL, PPC_OP_CRX, PPC_OP_IMM, PPC_OP_MEM, PPC_OP_REG, PPC_REG_INVALID, printf(), and PRIx64.

Referenced by print_details().

◆ print_string_hex()

void print_string_hex ( char *  comment,
unsigned char *  str,
size_t  len 
)