blob: e7e7c75e819f35d76cccf24d4bff4af04851a7b6 [file] [log] [blame]
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08001/* Capstone Disassembler Engine */
2/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
3
4#ifndef __CS_UTILS_H__
5#define __CS_UTILS_H__
6
7#include <stdbool.h>
8
9typedef struct Pair {
10 char *str;
11 unsigned num;
12} Pair;
13
14// map instruction to its characteristics
15typedef struct insn_map {
16 unsigned int id;
17 unsigned int mapid;
18 unsigned int regs_use[32]; // list of implicit registers used by this instruction
19 unsigned int regs_mod[32]; // list of implicit registers modified by this instruction
20 unsigned int groups[8]; // list of group this instruction belong to
21 bool branch; // branch instruction?
22 bool indirect_branch; // indirect branch instruction?
23} insn_map;
24
25bool str_in_list(char **list, char *s);
26
27int insn_find(insn_map *m, unsigned int max, unsigned int id);
28
29// map id to string
30typedef struct name_map {
31 unsigned int id;
32 char *name;
33} name_map;
34
35// map a name to its ID
36// return 0 if not found
37int name2id(name_map* map, int max, char *name);
38
39// reverse mapid to id
40// return 0 if not found
41unsigned int insn_reverse_id(insn_map *insns, unsigned int max, unsigned int id);
42
43#define ARR_SIZE(a) (sizeof(a)/sizeof(a[0]))
44
45#endif
46