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

Go to the source code of this file.

Functions

void print_string_hex (const char *comment, unsigned char *str, size_t len)
 
void print_insn_detail_tms320c64x (csh handle, cs_insn *ins)
 

Function Documentation

◆ print_insn_detail_tms320c64x()

void print_insn_detail_tms320c64x ( csh  handle,
cs_insn *  ins 
)

Definition at line 9 of file cstool_tms320c64x.c.

10 {
11  cs_tms320c64x *tms320c64x;
12  int i;
13 
14  // detail can be NULL on "data" instruction if SKIPDATA option is turned ON
15  if (ins->detail == NULL)
16  return;
17 
18  tms320c64x = &(ins->detail->tms320c64x);
19  if (tms320c64x->op_count)
20  printf("\top_count: %u\n", tms320c64x->op_count);
21 
22  for (i = 0; i < tms320c64x->op_count; i++) {
23  cs_tms320c64x_op *op = &(tms320c64x->operands[i]);
24  switch((int)op->type) {
25  default:
26  break;
27  case TMS320C64X_OP_REG:
28  printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
29  break;
30  case TMS320C64X_OP_IMM:
31  printf("\t\toperands[%u].type: IMM = 0x%x\n", i, op->imm);
32  break;
33  case TMS320C64X_OP_MEM:
34  printf("\t\toperands[%u].type: MEM\n", i);
35  if (op->mem.base != TMS320C64X_REG_INVALID)
36  printf("\t\t\toperands[%u].mem.base: REG = %s\n",
37  i, cs_reg_name(handle, op->mem.base));
38  printf("\t\t\toperands[%u].mem.disptype: ", i);
39  if(op->mem.disptype == TMS320C64X_MEM_DISP_INVALID) {
40  printf("Invalid\n");
41  printf("\t\t\toperands[%u].mem.disp: %u\n", i, op->mem.disp);
42  }
43  if(op->mem.disptype == TMS320C64X_MEM_DISP_CONSTANT) {
44  printf("Constant\n");
45  printf("\t\t\toperands[%u].mem.disp: %u\n", i, op->mem.disp);
46  }
47  if(op->mem.disptype == TMS320C64X_MEM_DISP_REGISTER) {
48  printf("Register\n");
49  printf("\t\t\toperands[%u].mem.disp: %s\n", i, cs_reg_name(handle, op->mem.disp));
50  }
51  printf("\t\t\toperands[%u].mem.unit: %u\n", i, op->mem.unit);
52  printf("\t\t\toperands[%u].mem.direction: ", i);
53  if(op->mem.direction == TMS320C64X_MEM_DIR_INVALID)
54  printf("Invalid\n");
55  if(op->mem.direction == TMS320C64X_MEM_DIR_FW)
56  printf("Forward\n");
57  if(op->mem.direction == TMS320C64X_MEM_DIR_BW)
58  printf("Backward\n");
59  printf("\t\t\toperands[%u].mem.modify: ", i);
60  if(op->mem.modify == TMS320C64X_MEM_MOD_INVALID)
61  printf("Invalid\n");
62  if(op->mem.modify == TMS320C64X_MEM_MOD_NO)
63  printf("No\n");
64  if(op->mem.modify == TMS320C64X_MEM_MOD_PRE)
65  printf("Pre\n");
66  if(op->mem.modify == TMS320C64X_MEM_MOD_POST)
67  printf("Post\n");
68  printf("\t\t\toperands[%u].mem.scaled: %u\n", i, op->mem.scaled);
69 
70  break;
72  printf("\t\toperands[%u].type: REGPAIR = %s:%s\n", i, cs_reg_name(handle, op->reg + 1), cs_reg_name(handle, op->reg));
73  break;
74  }
75  }
76 
77  printf("\tFunctional unit: ");
78  switch(tms320c64x->funit.unit) {
79  case TMS320C64X_FUNIT_D:
80  printf("D%u\n", tms320c64x->funit.side);
81  break;
82  case TMS320C64X_FUNIT_L:
83  printf("L%u\n", tms320c64x->funit.side);
84  break;
85  case TMS320C64X_FUNIT_M:
86  printf("M%u\n", tms320c64x->funit.side);
87  break;
88  case TMS320C64X_FUNIT_S:
89  printf("S%u\n", tms320c64x->funit.side);
90  break;
92  printf("No Functional Unit\n");
93  break;
94  default:
95  printf("Unknown (Unit %u, Side %u)\n", tms320c64x->funit.unit, tms320c64x->funit.side);
96  break;
97  }
98  if(tms320c64x->funit.crosspath == 1)
99  printf("\tCrosspath: 1\n");
100 
101  if(tms320c64x->condition.reg != TMS320C64X_REG_INVALID)
102  printf("\tCondition: [%c%s]\n", (tms320c64x->condition.zero == 1) ? '!' : ' ', cs_reg_name(handle, tms320c64x->condition.reg));
103  printf("\tParallel: %s\n", (tms320c64x->parallel == 1) ? "true" : "false");
104 
105  printf("\n");
106 }
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
cs_tms320c64x_op operands[8]
operands for this instruction.
Definition: tms320c64x.h:66
struct cs_tms320c64x::@364 funit
unsigned int unit
Definition: tms320c64x.h:72
unsigned int parallel
Definition: tms320c64x.h:76
unsigned int crosspath
Definition: tms320c64x.h:74
unsigned int reg
Definition: tms320c64x.h:68
uint8_t op_count
Definition: tms320c64x.h:65
struct cs_tms320c64x::@363 condition
unsigned int zero
Definition: tms320c64x.h:69
unsigned int side
Definition: tms320c64x.h:73
@ TMS320C64X_FUNIT_NO
Definition: tms320c64x.h:351
@ TMS320C64X_FUNIT_L
Definition: tms320c64x.h:348
@ TMS320C64X_FUNIT_D
Definition: tms320c64x.h:347
@ TMS320C64X_FUNIT_S
Definition: tms320c64x.h:350
@ TMS320C64X_FUNIT_M
Definition: tms320c64x.h:349
@ TMS320C64X_MEM_DISP_INVALID
Definition: tms320c64x.h:27
@ TMS320C64X_MEM_DISP_CONSTANT
Definition: tms320c64x.h:28
@ TMS320C64X_MEM_DISP_REGISTER
Definition: tms320c64x.h:29
@ TMS320C64X_REG_INVALID
Definition: tms320c64x.h:80
@ TMS320C64X_MEM_DIR_FW
Definition: tms320c64x.h:34
@ TMS320C64X_MEM_DIR_BW
Definition: tms320c64x.h:35
@ TMS320C64X_MEM_DIR_INVALID
Definition: tms320c64x.h:33
@ TMS320C64X_MEM_MOD_POST
Definition: tms320c64x.h:42
@ TMS320C64X_MEM_MOD_INVALID
Definition: tms320c64x.h:39
@ TMS320C64X_MEM_MOD_NO
Definition: tms320c64x.h:40
@ TMS320C64X_MEM_MOD_PRE
Definition: tms320c64x.h:41
@ TMS320C64X_OP_REG
= CS_OP_REG (Register operand).
Definition: tms320c64x.h:20
@ TMS320C64X_OP_REGPAIR
Register pair for double word ops.
Definition: tms320c64x.h:23
@ TMS320C64X_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: tms320c64x.h:21
@ TMS320C64X_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: tms320c64x.h:22
Definition: dis.c:32

References cs_tms320c64x::condition, cs_tms320c64x::crosspath, cs_reg_name(), cs_tms320c64x::funit, handle, i, NULL, cs_tms320c64x::op_count, cs_tms320c64x::operands, cs_tms320c64x::parallel, printf(), cs_tms320c64x::reg, cs_tms320c64x::side, TMS320C64X_FUNIT_D, TMS320C64X_FUNIT_L, TMS320C64X_FUNIT_M, TMS320C64X_FUNIT_NO, TMS320C64X_FUNIT_S, TMS320C64X_MEM_DIR_BW, TMS320C64X_MEM_DIR_FW, TMS320C64X_MEM_DIR_INVALID, TMS320C64X_MEM_DISP_CONSTANT, TMS320C64X_MEM_DISP_INVALID, TMS320C64X_MEM_DISP_REGISTER, TMS320C64X_MEM_MOD_INVALID, TMS320C64X_MEM_MOD_NO, TMS320C64X_MEM_MOD_POST, TMS320C64X_MEM_MOD_PRE, TMS320C64X_OP_IMM, TMS320C64X_OP_MEM, TMS320C64X_OP_REG, TMS320C64X_OP_REGPAIR, TMS320C64X_REG_INVALID, cs_tms320c64x::unit, and cs_tms320c64x::zero.

Referenced by print_details().

◆ print_string_hex()

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

Definition at line 91 of file cstool.c.

92 {
93  unsigned char *c;
94 
95  printf("%s", comment);
96  for (c = str; c < str + len; c++) {
97  printf("0x%02x ", *c & 0xff);
98  }
99 
100  printf("\n");
101 }
size_t len
Definition: 6502dis.c:15
#define c(i)
Definition: sha256.c:43