comparison udis86-1.4/libudis86/opcmap.h @ 1:4a9dcbd9e54f

-files of 0.13 beta -fixes so that it now compiles with the current dmd version
author marton@basel.hu
date Tue, 05 Apr 2011 20:44:01 +0200
parents
children
comparison
equal deleted inserted replaced
0:586e4a649642 1:4a9dcbd9e54f
1 /* -----------------------------------------------------------------------------
2 * opcmap.h
3 *
4 * Copyright (c) 2005, 2006, Vivek Mohan <vivek@sig9.com>
5 * All rights reserved. See LICENSE
6 * -----------------------------------------------------------------------------
7 */
8 #ifndef UD_OPCMAP_H
9 #define UD_OPCMAP_H
10
11 #include "types.h"
12
13 /* Prefixes/Macros */
14
15 #define Pnone 0x00
16 #define Pa32 0x01
17 #define P_A32(n) ((n) & 0x01)
18 #define Po32 0x04
19 #define P_O32(n) ((n) & 0x04)
20 #define Pdef64 0x08
21 #define P_DEF64(n) ((n) & 0x08)
22 #define Pinv64 0x10
23 #define P_INV64(n) ((n) & 0x10)
24 #define Pc1 0x20
25 #define P_C1(n) ((n) & 0x20)
26 #define Pc2 0x40
27 #define P_C2(n) ((n) & 0x40)
28 #define Pc3 0x80
29 #define P_C3(n) ((n) & 0x80)
30 #define PdepM 0x100
31 #define P_DEPM(n) ((n) & 0x100)
32 #define REX(c) ((0x40 | c) << 16)
33 #define P_REX(c) (c & 0xFF0000)
34 #define P_REX_MASK(n) (0x40 | (0xF & ((n) >> 16)))
35 #define _W 8
36 #define _R 4
37 #define _X 2
38 #define _B 1
39 #define P_REX_W(r) ((0xF & (r)) >> 3)
40 #define P_REX_R(r) ((0x7 & (r)) >> 2)
41 #define P_REX_X(r) ((0x3 & (r)) >> 1)
42 #define P_REX_B(r) ((0x1 & (r)) >> 0)
43 #define SIB_S(b) ((b) >> 6)
44 #define SIB_I(b) (((b) >> 3) & 7)
45 #define SIB_B(b) ((b) & 7)
46 #define MODRM_REG(b) (((b) >> 3) & 7)
47 #define MODRM_NNN(b) (((b) >> 3) & 7)
48 #define MODRM_MOD(b) (((b) >> 6) & 3)
49 #define MODRM_RM(b) ((b) & 7)
50
51 #define SZ_Z 1
52 #define SZ_V 2
53 #define SZ_P 3
54 #define SZ_WP 4
55 #define SZ_DP 5
56 #define SZ_MDQ 6
57 #define SZ_RDQ 7
58 #define SZ_B 8
59 #define SZ_W 16
60 #define SZ_D 32
61 #define SZ_Q 64
62 #define SZ_T 80
63
64 /* -----------------------------------------------------------------------------
65 * Enumeration of types of the operands in the opcode map. The naming was
66 * inspired by the AMD manuals. To understand the specifics, read the manuals.
67 * -----------------------------------------------------------------------------
68 */
69 enum map_operand_type
70 {
71 OP_NONE = 0,
72 OP_A,
73 OP_E,
74 OP_M,
75 OP_G,
76 OP_I,
77 OP_AL,
78 OP_CL,
79 OP_DL,
80 OP_BL,
81 OP_AH,
82 OP_CH,
83 OP_DH,
84 OP_BH,
85 OP_ALr8b,
86 OP_CLr9b,
87 OP_DLr10b,
88 OP_BLr11b,
89 OP_AHr12b,
90 OP_CHr13b,
91 OP_DHr14b,
92 OP_BHr15b,
93 OP_AX,
94 OP_CX,
95 OP_DX,
96 OP_BX,
97 OP_SI,
98 OP_DI,
99 OP_SP,
100 OP_BP,
101 OP_rAX,
102 OP_rCX,
103 OP_rDX,
104 OP_rBX,
105 OP_rSP,
106 OP_rBP,
107 OP_rSI,
108 OP_rDI,
109 OP_rAXr8,
110 OP_rCXr9,
111 OP_rDXr10,
112 OP_rBXr11,
113 OP_rSPr12,
114 OP_rBPr13,
115 OP_rSIr14,
116 OP_rDIr15,
117 OP_eAX,
118 OP_eCX,
119 OP_eDX,
120 OP_eBX,
121 OP_eSP,
122 OP_eBP,
123 OP_eSI,
124 OP_eDI,
125 OP_ES,
126 OP_CS,
127 OP_SS,
128 OP_DS,
129 OP_FS,
130 OP_GS,
131 OP_ST0,
132 OP_ST1,
133 OP_ST2,
134 OP_ST3,
135 OP_ST4,
136 OP_ST5,
137 OP_ST6,
138 OP_ST7,
139 OP_J,
140 OP_S,
141 OP_O,
142 OP_I1,
143 OP_I3,
144 OP_V,
145 OP_W,
146 OP_Q,
147 OP_P,
148 OP_R,
149 OP_C,
150 OP_D,
151 OP_VR,
152 OP_PR
153 };
154
155 struct map_operand
156 {
157 enum map_operand_type type;
158 uint8_t size;
159 };
160
161 struct map_entry
162 {
163 enum ud_mnemonic_code mnemonic;
164 struct map_operand operand1;
165 struct map_operand operand2;
166 struct map_operand operand3;
167 uint32_t prefix;
168 };
169
170 void ud_search_map(struct ud*);
171 enum ud_mnemonic_code ud_map_get_3dnow(uint8_t);
172
173 #endif