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.h>
8 
9 void print_string_hex(char *comment, unsigned char *str, size_t len);
10 
print_insn_detail_mips(csh handle,cs_insn * ins)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 != X86_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 }
48