Rizin
unix-like reverse engineering framework and cli tools
cstool_mips.c
Go to the documentation of this file.
1 /* Capstone Disassembler Engine */
2 /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 
7 #include <capstone/capstone.h>
8 
9 void print_string_hex(char *comment, unsigned char *str, size_t len);
10 
11 void print_insn_detail_mips(csh handle, cs_insn *ins)
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 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
static mcore_handle handle
Definition: asm_mcore.c:8
size_t csh
Definition: capstone.h:71
#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
void print_string_hex(char *comment, unsigned char *str, size_t len)
void print_insn_detail_mips(csh handle, cs_insn *ins)
Definition: cstool_mips.c:11
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