/[pearpc]/src/debug/x86opc.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /src/debug/x86opc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Wed Sep 5 17:11:21 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 4991 byte(s)
import upstream CVS
1 dpavlin 1 /*
2     * HT Editor
3     * x86opc.h
4     *
5     * Copyright (C) 1999-2002 Stefan Weyergraf
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License version 2 as
9     * published by the Free Software Foundation.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19     */
20    
21     #ifndef __X86OPC_H__
22     #define __X86OPC_H__
23    
24     #include "system/types.h"
25    
26     #define X86_PREFIX_NO -1
27    
28     #define X86_PREFIX_LOCK 0 /* f0 */
29    
30     #define X86_PREFIX_ES 0 /* 26 */
31     #define X86_PREFIX_CS 1 /* 2e */
32     #define X86_PREFIX_SS 2 /* 36 */
33     #define X86_PREFIX_DS 3 /* 3e */
34     #define X86_PREFIX_FS 4 /* 64 */
35     #define X86_PREFIX_GS 5 /* 65 */
36    
37     #define X86_PREFIX_REPNZ 0 /* f2 */
38     #define X86_PREFIX_REPZ 1 /* f3 */
39    
40     #define X86_OPSIZEUNKNOWN -1
41     #define X86_OPSIZE16 0
42     #define X86_OPSIZE32 1
43    
44     #define X86_ADDRSIZEUNKNOWN -1
45     #define X86_ADDRSIZE16 0
46     #define X86_ADDRSIZE32 1
47    
48     #define X86_OPTYPE_EMPTY 0
49     #define X86_OPTYPE_IMM 1
50     #define X86_OPTYPE_REG 2
51     #define X86_OPTYPE_SEG 3
52     #define X86_OPTYPE_MEM 4
53     #define X86_OPTYPE_CRX 5
54     #define X86_OPTYPE_DRX 6
55     #define X86_OPTYPE_TRX 7
56     #define X86_OPTYPE_STX 8
57     #define X86_OPTYPE_MMX 9
58     #define X86_OPTYPE_FARPTR 10
59    
60     // user defined types start here
61     #define X86_OPTYPE_USER 32
62    
63     union int_or_ptr {
64     int i;
65     void *p;
66     };
67    
68     #define dword uint32
69    
70     struct x86_insn_op {
71     int type;
72     int size;
73     union {
74     struct {
75     dword seg;
76     dword offset;
77     } farptr;
78     dword imm;
79     int reg;
80     int seg;
81     struct {
82     int floatptr;
83     int hasdisp;
84     dword disp;
85     int base;
86     int index;
87     int scale;
88     int addrsize;
89     } mem;
90     int crx;
91     int drx;
92     int trx;
93     int stx;
94     int mmx;
95     int_or_ptr user[4];
96     };
97     };
98    
99     #define TYPE_0 0
100     #define TYPE_A 1 /* direct address without ModR/M (generally
101     like imm, but can be 16:32 = 48 bit) */
102     #define TYPE_C 2 /* reg of ModR/M picks control register */
103     #define TYPE_D 3 /* reg of ModR/M picks debug register */
104     #define TYPE_E 4 /* ModR/M (general reg or memory) */
105     #define TYPE_G 5 /* reg of ModR/M picks general register */
106     #define TYPE_Is 6 /* signed immediate */
107     #define TYPE_I 7 /* unsigned immediate */
108     #define TYPE_Ix 8 /* fixed immediate */
109     #define TYPE_J 9 /* relative branch offset */
110     #define TYPE_M 10 /* ModR/M (memory only) */
111     #define TYPE_O 11 /* direct memory without ModR/M */
112     #define TYPE_P 12 /* reg of ModR/M picks MMX register */
113     #define TYPE_Q 13 /* ModR/M (MMX reg or memory) */
114     #define TYPE_R 14 /* rm of ModR/M picks general register */
115     #define TYPE_Rx 15 /* extra picks register */
116     #define TYPE_S 16 /* reg of ModR/M picks segment register */
117     #define TYPE_Sx 17 /* extra picks segment register */
118     #define TYPE_T 18 /* reg of ModR/M picks test register */
119     #define TYPE_F 19 /* r/m of ModR/M picks a fpu register */
120     #define TYPE_Fx 20 /* extra picks a fpu register */
121    
122     /* when name is == 0, the first op has a special meaning (layout see x86_insn_op_special) */
123     #define SPECIAL_TYPE_INVALID 0
124     #define SPECIAL_TYPE_PREFIX 1
125     #define SPECIAL_TYPE_GROUP 2
126     #define SPECIAL_TYPE_FGROUP 3
127    
128     #define SIZE_0 '0' /* size unimportant */
129     #define SIZE_B 'b' /* byte */
130     #define SIZE_W 'w' /* word */
131     #define SIZE_D 'd' /* dword */
132     #define SIZE_Q 'q' /* qword */
133     #define SIZE_C 'c' /* byte OR word */
134     #define SIZE_V 'v' /* word OR dword */
135     #define SIZE_P 'p' /* word:word OR word:dword, memory only ! */
136     #define SIZE_S 's' /* short/single real (32-bit) */
137     #define SIZE_L 'l' /* long/double real (64-bit) */
138     #define SIZE_T 't' /* temp/extended real (80-bit) */
139     #define SIZE_A 'a' /* packed decimal (80-bit BCD) */
140    
141     struct x86opc_insn_op {
142     char type;
143     char extra;
144     char size;
145     char extendedsize;
146     };
147    
148     struct x86opc_insn_op_special {
149     char type;
150     char data;
151     char res1;
152     char res2;
153     };
154    
155     struct x86opc_insn {
156     char *name;
157     x86opc_insn_op op[3];
158     };
159    
160     /* this can be a group (group!=0), an insn (group==0) && (insn.name!=0) or
161     (otherwise) a reserved instruction. */
162     struct x86opc_finsn {
163     x86opc_insn *group;
164     x86opc_insn insn;
165     };
166    
167     #define X86_REG_INVALID -2
168     #define X86_REG_NO -1
169     #define X86_REG_AX 0
170     #define X86_REG_CX 1
171     #define X86_REG_DX 2
172     #define X86_REG_BX 3
173     #define X86_REG_SP 4
174     #define X86_REG_BP 5
175     #define X86_REG_SI 6
176     #define X86_REG_DI 7
177    
178     #define X86_GROUPS 20
179    
180     extern char *x86_regs[3][8];
181     extern char *x86_segs[8];
182     extern x86opc_insn x86_insns[256];
183     extern x86opc_insn x86_insns_ext[256];
184     extern x86opc_insn x86_group_insns[X86_GROUPS][8];
185    
186     extern x86opc_insn x86_modfloat_group_insns[8][8];
187     extern x86opc_finsn x86_float_group_insns[8][8];
188    
189     #endif /* __X86OPC_H__ */

  ViewVC Help
Powered by ViewVC 1.1.26