• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Capstone testing regression */
2 /* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
3 
4 
5 #include "factory.h"
6 
get_detail_mips(csh * handle,cs_mode mode,cs_insn * ins)7 char *get_detail_mips(csh *handle, cs_mode mode, cs_insn *ins)
8 {
9 	int i;
10 	cs_mips *mips;
11 	char *result;
12 
13 	result = (char *)malloc(sizeof(char));
14 	result[0] = '\0';
15 
16 	if (ins->detail == NULL)
17 		return result;
18 
19 	mips = &(ins->detail->mips);
20 	if (mips->op_count)
21 		add_str(&result, " ; op_count: %u", mips->op_count);
22 
23 	for (i = 0; i < mips->op_count; i++) {
24 		cs_mips_op *op = &(mips->operands[i]);
25 		switch((int)op->type) {
26 			default:
27 				break;
28 			case MIPS_OP_REG:
29 				add_str(&result, " ; operands[%u].type: REG = %s", i, cs_reg_name(*handle, op->reg));
30 				break;
31 			case MIPS_OP_IMM:
32 				add_str(&result, " ; operands[%u].type: IMM = 0x%" PRIx64 "", i, op->imm);
33 				break;
34 			case MIPS_OP_MEM:
35 				add_str(&result, " ; operands[%u].type: MEM", i);
36 				if (op->mem.base != MIPS_REG_INVALID)
37 					add_str(&result, " ; operands[%u].mem.base: REG = %s", i, cs_reg_name(*handle, op->mem.base));
38 				if (op->mem.disp != 0)
39 					add_str(&result, " ; operands[%u].mem.disp: 0x%" PRIx64 "", i, op->mem.disp);
40 
41 				break;
42 		}
43 
44 	}
45 
46 	return result;
47 }
48 
49