• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Capstone Disassembly Engine */
2 /* By Dang Hoang Vu <danghvu@gmail.com> 2013 */
3 
4 #ifdef CAPSTONE_HAS_MIPS
5 
6 #include "../../utils.h"
7 #include "../../MCRegisterInfo.h"
8 #include "MipsDisassembler.h"
9 #include "MipsInstPrinter.h"
10 #include "MipsMapping.h"
11 #include "MipsModule.h"
12 
13 // Returns mode value with implied bits set
updated_mode(cs_mode mode)14 static cs_mode updated_mode(cs_mode mode)
15 {
16 	if (mode & CS_MODE_MIPS32R6) {
17 		mode |= CS_MODE_32;
18 	}
19 
20 	return mode;
21 }
22 
Mips_global_init(cs_struct * ud)23 cs_err Mips_global_init(cs_struct *ud)
24 {
25 	MCRegisterInfo *mri;
26 	mri = cs_mem_malloc(sizeof(*mri));
27 
28 	Mips_init(mri);
29 	ud->printer = Mips_printInst;
30 	ud->printer_info = mri;
31 	ud->getinsn_info = mri;
32 	ud->reg_name = Mips_reg_name;
33 	ud->insn_id = Mips_get_insn_id;
34 	ud->insn_name = Mips_insn_name;
35 	ud->group_name = Mips_group_name;
36 
37 	ud->disasm = Mips_getInstruction;
38 
39 	return CS_ERR_OK;
40 }
41 
Mips_option(cs_struct * handle,cs_opt_type type,size_t value)42 cs_err Mips_option(cs_struct *handle, cs_opt_type type, size_t value)
43 {
44 	if (type == CS_OPT_MODE) {
45 		handle->mode = updated_mode(value);
46 		return CS_ERR_OK;
47 	}
48 
49 	return CS_ERR_OPTION;
50 }
51 
52 #endif
53