root / exec-i386.h @ cabb4d61
History | View | Annotate | Download (5 kB)
1 | 3ef693a0 | bellard | /*
|
---|---|---|---|
2 | 3ef693a0 | bellard | * i386 execution defines
|
3 | 3ef693a0 | bellard | *
|
4 | 3ef693a0 | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 3ef693a0 | bellard | *
|
6 | 3ef693a0 | bellard | * This library is free software; you can redistribute it and/or
|
7 | 3ef693a0 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 3ef693a0 | bellard | * License as published by the Free Software Foundation; either
|
9 | 3ef693a0 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 3ef693a0 | bellard | *
|
11 | 3ef693a0 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 3ef693a0 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 3ef693a0 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 3ef693a0 | bellard | * Lesser General Public License for more details.
|
15 | 3ef693a0 | bellard | *
|
16 | 3ef693a0 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 3ef693a0 | bellard | * License along with this library; if not, write to the Free Software
|
18 | 3ef693a0 | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 3ef693a0 | bellard | */
|
20 | 7d13299d | bellard | typedef unsigned char uint8_t; |
21 | 7d13299d | bellard | typedef unsigned short uint16_t; |
22 | 7d13299d | bellard | typedef unsigned int uint32_t; |
23 | 7d13299d | bellard | typedef unsigned long long uint64_t; |
24 | 7d13299d | bellard | |
25 | 7d13299d | bellard | typedef signed char int8_t; |
26 | 7d13299d | bellard | typedef signed short int16_t; |
27 | 7d13299d | bellard | typedef signed int int32_t; |
28 | 7d13299d | bellard | typedef signed long long int64_t; |
29 | 7d13299d | bellard | |
30 | 7d13299d | bellard | #define bswap32(x) \
|
31 | 7d13299d | bellard | ({ \ |
32 | 7d13299d | bellard | uint32_t __x = (x); \ |
33 | 7d13299d | bellard | ((uint32_t)( \ |
34 | 7d13299d | bellard | (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ |
35 | 7d13299d | bellard | (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ |
36 | 7d13299d | bellard | (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ |
37 | 7d13299d | bellard | (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ |
38 | 7d13299d | bellard | }) |
39 | 7d13299d | bellard | |
40 | 7d13299d | bellard | #define NULL 0 |
41 | 7d13299d | bellard | #include <fenv.h> |
42 | 7d13299d | bellard | |
43 | 7d13299d | bellard | typedef struct FILE FILE; |
44 | 7d13299d | bellard | extern FILE *logfile;
|
45 | 7d13299d | bellard | extern int loglevel; |
46 | 7d13299d | bellard | extern int fprintf(FILE *, const char *, ...); |
47 | 6dbad63e | bellard | extern int printf(const char *, ...); |
48 | 7d13299d | bellard | |
49 | 7d13299d | bellard | #ifdef __i386__
|
50 | 7d13299d | bellard | register unsigned int T0 asm("ebx"); |
51 | 7d13299d | bellard | register unsigned int T1 asm("esi"); |
52 | 7d13299d | bellard | register unsigned int A0 asm("edi"); |
53 | 7d13299d | bellard | register struct CPUX86State *env asm("ebp"); |
54 | 7d13299d | bellard | #endif
|
55 | 7d13299d | bellard | #ifdef __powerpc__
|
56 | 04369ff2 | bellard | register unsigned int EAX asm("r16"); |
57 | 04369ff2 | bellard | register unsigned int ECX asm("r17"); |
58 | 04369ff2 | bellard | register unsigned int EDX asm("r18"); |
59 | 04369ff2 | bellard | register unsigned int EBX asm("r19"); |
60 | 04369ff2 | bellard | register unsigned int ESP asm("r20"); |
61 | 04369ff2 | bellard | register unsigned int EBP asm("r21"); |
62 | 04369ff2 | bellard | register unsigned int ESI asm("r22"); |
63 | 04369ff2 | bellard | register unsigned int EDI asm("r23"); |
64 | 7d13299d | bellard | register unsigned int T0 asm("r24"); |
65 | 7d13299d | bellard | register unsigned int T1 asm("r25"); |
66 | 7d13299d | bellard | register unsigned int A0 asm("r26"); |
67 | 7d13299d | bellard | register struct CPUX86State *env asm("r27"); |
68 | 04369ff2 | bellard | #define USE_INT_TO_FLOAT_HELPERS
|
69 | d03cda59 | bellard | #define BUGGY_GCC_DIV64
|
70 | 04369ff2 | bellard | #define reg_EAX
|
71 | 04369ff2 | bellard | #define reg_ECX
|
72 | 04369ff2 | bellard | #define reg_EDX
|
73 | 04369ff2 | bellard | #define reg_EBX
|
74 | 04369ff2 | bellard | #define reg_ESP
|
75 | 04369ff2 | bellard | #define reg_EBP
|
76 | 04369ff2 | bellard | #define reg_ESI
|
77 | 04369ff2 | bellard | #define reg_EDI
|
78 | 7d13299d | bellard | #endif
|
79 | 7d13299d | bellard | #ifdef __arm__
|
80 | 7d13299d | bellard | register unsigned int T0 asm("r4"); |
81 | 7d13299d | bellard | register unsigned int T1 asm("r5"); |
82 | 7d13299d | bellard | register unsigned int A0 asm("r6"); |
83 | 7d13299d | bellard | register struct CPUX86State *env asm("r7"); |
84 | 7d13299d | bellard | #endif
|
85 | 7d13299d | bellard | #ifdef __mips__
|
86 | 7d13299d | bellard | register unsigned int T0 asm("s0"); |
87 | 7d13299d | bellard | register unsigned int T1 asm("s1"); |
88 | 7d13299d | bellard | register unsigned int A0 asm("s2"); |
89 | 7d13299d | bellard | register struct CPUX86State *env asm("s3"); |
90 | 7d13299d | bellard | #endif
|
91 | 7d13299d | bellard | #ifdef __sparc__
|
92 | 7d13299d | bellard | register unsigned int T0 asm("l0"); |
93 | 7d13299d | bellard | register unsigned int T1 asm("l1"); |
94 | 7d13299d | bellard | register unsigned int A0 asm("l2"); |
95 | 7d13299d | bellard | register struct CPUX86State *env asm("l3"); |
96 | d014c98c | bellard | #define USE_FP_CONVERT
|
97 | 7d13299d | bellard | #endif
|
98 | fb3e5849 | bellard | #ifdef __s390__
|
99 | fb3e5849 | bellard | register unsigned int T0 asm("r7"); |
100 | fb3e5849 | bellard | register unsigned int T1 asm("r8"); |
101 | fb3e5849 | bellard | register unsigned int A0 asm("r9"); |
102 | fb3e5849 | bellard | register struct CPUX86State *env asm("r10"); |
103 | fb3e5849 | bellard | #endif
|
104 | d03cda59 | bellard | #ifdef __alpha__
|
105 | d03cda59 | bellard | register unsigned int T0 asm("$9"); |
106 | d03cda59 | bellard | register unsigned int T1 asm("$10"); |
107 | d03cda59 | bellard | register unsigned int A0 asm("$11"); |
108 | d03cda59 | bellard | register struct CPUX86State *env asm("$12"); |
109 | d03cda59 | bellard | #endif
|
110 | 0d330196 | bellard | #ifdef __ia64__
|
111 | 0d330196 | bellard | register unsigned int T0 asm("r24"); |
112 | 0d330196 | bellard | register unsigned int T1 asm("r25"); |
113 | 0d330196 | bellard | register unsigned int A0 asm("r26"); |
114 | 0d330196 | bellard | register struct CPUX86State *env asm("r27"); |
115 | 0d330196 | bellard | #endif
|
116 | 7d13299d | bellard | |
117 | 7d13299d | bellard | /* force GCC to generate only one epilog at the end of the function */
|
118 | 7d13299d | bellard | #define FORCE_RET() asm volatile (""); |
119 | 7d13299d | bellard | |
120 | 7d13299d | bellard | #ifndef OPPROTO
|
121 | 7d13299d | bellard | #define OPPROTO
|
122 | 7d13299d | bellard | #endif
|
123 | 7d13299d | bellard | |
124 | 7d13299d | bellard | #define xglue(x, y) x ## y |
125 | 7d13299d | bellard | #define glue(x, y) xglue(x, y)
|
126 | 7d13299d | bellard | |
127 | 04369ff2 | bellard | #ifndef reg_EAX
|
128 | 7d13299d | bellard | #define EAX (env->regs[R_EAX])
|
129 | 04369ff2 | bellard | #endif
|
130 | 04369ff2 | bellard | #ifndef reg_ECX
|
131 | 7d13299d | bellard | #define ECX (env->regs[R_ECX])
|
132 | 04369ff2 | bellard | #endif
|
133 | 04369ff2 | bellard | #ifndef reg_EDX
|
134 | 7d13299d | bellard | #define EDX (env->regs[R_EDX])
|
135 | 04369ff2 | bellard | #endif
|
136 | 04369ff2 | bellard | #ifndef reg_EBX
|
137 | 7d13299d | bellard | #define EBX (env->regs[R_EBX])
|
138 | 04369ff2 | bellard | #endif
|
139 | 04369ff2 | bellard | #ifndef reg_ESP
|
140 | 7d13299d | bellard | #define ESP (env->regs[R_ESP])
|
141 | 04369ff2 | bellard | #endif
|
142 | 04369ff2 | bellard | #ifndef reg_EBP
|
143 | 7d13299d | bellard | #define EBP (env->regs[R_EBP])
|
144 | 04369ff2 | bellard | #endif
|
145 | 04369ff2 | bellard | #ifndef reg_ESI
|
146 | 7d13299d | bellard | #define ESI (env->regs[R_ESI])
|
147 | 04369ff2 | bellard | #endif
|
148 | 04369ff2 | bellard | #ifndef reg_EDI
|
149 | 7d13299d | bellard | #define EDI (env->regs[R_EDI])
|
150 | 04369ff2 | bellard | #endif
|
151 | dab2ed99 | bellard | #define EIP (env->eip)
|
152 | 7d13299d | bellard | #define DF (env->df)
|
153 | 7d13299d | bellard | |
154 | 7d13299d | bellard | #define CC_SRC (env->cc_src)
|
155 | 7d13299d | bellard | #define CC_DST (env->cc_dst)
|
156 | 7d13299d | bellard | #define CC_OP (env->cc_op)
|
157 | 7d13299d | bellard | |
158 | 7d13299d | bellard | /* float macros */
|
159 | 7d13299d | bellard | #define FT0 (env->ft0)
|
160 | 7d13299d | bellard | #define ST0 (env->fpregs[env->fpstt])
|
161 | 7d13299d | bellard | #define ST(n) (env->fpregs[(env->fpstt + (n)) & 7]) |
162 | 7d13299d | bellard | #define ST1 ST(1) |
163 | 7d13299d | bellard | |
164 | d014c98c | bellard | #ifdef USE_FP_CONVERT
|
165 | d014c98c | bellard | #define FP_CONVERT (env->fp_convert)
|
166 | d014c98c | bellard | #endif
|
167 | d014c98c | bellard | |
168 | 7d13299d | bellard | extern int __op_param1, __op_param2, __op_param3; |
169 | 7d13299d | bellard | #define PARAM1 ((long)(&__op_param1)) |
170 | 7d13299d | bellard | #define PARAM2 ((long)(&__op_param2)) |
171 | 7d13299d | bellard | #define PARAM3 ((long)(&__op_param3)) |
172 | 7d13299d | bellard | |
173 | 7d13299d | bellard | #include "cpu-i386.h" |
174 | 7d13299d | bellard | |
175 | 7d13299d | bellard | typedef struct CCTable { |
176 | 7d13299d | bellard | int (*compute_all)(void); /* return all the flags */ |
177 | 7d13299d | bellard | int (*compute_c)(void); /* return the C flag */ |
178 | 7d13299d | bellard | } CCTable; |
179 | 7d13299d | bellard | |
180 | 7d13299d | bellard | extern CCTable cc_table[];
|
181 | 6dbad63e | bellard | |
182 | 6dbad63e | bellard | void load_seg(int seg_reg, int selector); |
183 | 1b6b029e | bellard | void cpu_lock(void); |
184 | 1b6b029e | bellard | void cpu_unlock(void); |
185 | 455b7619 | bellard | void raise_exception_err(int exception_index, int error_code); |
186 | 9de5e440 | bellard | void raise_exception(int exception_index); |
187 | 9de5e440 | bellard | |
188 | 9de5e440 | bellard | void OPPROTO op_movl_eflags_T0(void); |
189 | 9de5e440 | bellard | void OPPROTO op_movl_T0_eflags(void); |