Rizin
unix-like reverse engineering framework and cli tools
cstool_mips.c File Reference
#include <stdio.h>
#include <stdlib.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)
 
void print_insn_detail_mips (csh handle, cs_insn *ins)
 

Function Documentation

◆ print_insn_detail_mips()

void print_insn_detail_mips ( csh  handle,
cs_insn *  ins 
)

Definition at line 11 of file cstool_mips.c.

12 {
13  int i;
14  cs_mips *mips;
15 
16  // detail can be NULL on "data" instruction if SKIPDATA option is turned ON
17  if (ins->detail == NULL)
18  return;
19 
20  mips = &(ins->detail->mips);
21  if (mips->op_count)
22  printf("\top_count: %u\n", mips->op_count);
23 
24  for (i = 0; i < mips->op_count; i++) {
25  cs_mips_op *op = &(mips->operands[i]);
26  switch((int)op->type) {
27  default:
28  break;
29  case MIPS_OP_REG:
30  printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
31  break;
32  case MIPS_OP_IMM:
33  printf("\t\toperands[%u].type: IMM = 0x%" PRIx64 "\n", i, op->imm);
34  break;
35  case MIPS_OP_MEM:
36  printf("\t\toperands[%u].type: MEM\n", i);
37  if (op->mem.base != MIPS_REG_INVALID)
38  printf("\t\t\toperands[%u].mem.base: REG = %s\n",
39  i, cs_reg_name(handle, op->mem.base));
40  if (op->mem.disp != 0)
41  printf("\t\t\toperands[%u].mem.disp: 0x%" PRIx64 "\n", i, op->mem.disp);
42 
43  break;
44  }
45 
46  }
47 }
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
Instruction operand.
Definition: mips.h:240
Instruction structure.
Definition: mips.h:250
@ MIPS_OP_REG
= CS_OP_REG (Register operand).
Definition: mips.h:24
@ MIPS_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: mips.h:25
@ MIPS_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: mips.h:26
@ MIPS_REG_INVALID
Definition: mips.h:31
#define PRIx64
Definition: sysdefs.h:94
Definition: dis.c:32

References cs_reg_name(), handle, i, MIPS_OP_IMM, MIPS_OP_MEM, MIPS_OP_REG, MIPS_REG_INVALID, NULL, printf(), and PRIx64.

Referenced by print_details().

◆ print_string_hex()

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