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 }
print_string_hex
void print_string_hex(char *comment, unsigned char *str, size_t len)
xds_interop_client.str
str
Definition: xds_interop_client.py:487
MIPS_OP_REG
@ MIPS_OP_REG
= CS_OP_REG (Register operand).
Definition: mips.h:24
MIPS_OP_MEM
@ MIPS_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: mips.h:26
printf
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
Definition: cs_driver.c:91
print_insn_detail_mips
void print_insn_detail_mips(csh handle, cs_insn *ins)
Definition: cstool_mips.c:11
capstone.h
cs_reg_name
const CAPSTONE_EXPORT char *CAPSTONE_API cs_reg_name(csh ud, unsigned int reg)
Definition: cs.c:1176
MIPS_REG_INVALID
@ MIPS_REG_INVALID
Definition: mips.h:31
csh
size_t csh
Definition: capstone.h:71
cs_mips_op
Instruction operand.
Definition: mips.h:240
handle
static csh handle
Definition: test_arm_regression.c:16
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
MIPS_OP_IMM
@ MIPS_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: mips.h:25
mips
Definition: test_winkernel.cpp:63
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
cs_mips
Instruction structure.
Definition: mips.h:250
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:08