root / exec-i386.h @ b6d78bfa
History | View | Annotate | Download (9.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 | 79638566 | bellard | #include "dyngen-exec.h" |
21 | 79638566 | bellard | |
22 | 79638566 | bellard | /* at least 4 register variables are defines */
|
23 | 79638566 | bellard | register struct CPUX86State *env asm(AREG0); |
24 | 79638566 | bellard | register uint32_t T0 asm(AREG1); |
25 | 79638566 | bellard | register uint32_t T1 asm(AREG2); |
26 | 79638566 | bellard | register uint32_t T2 asm(AREG3); |
27 | 79638566 | bellard | |
28 | 79638566 | bellard | #define A0 T2
|
29 | 79638566 | bellard | |
30 | 79638566 | bellard | /* if more registers are available, we define some registers too */
|
31 | 79638566 | bellard | #ifdef AREG4
|
32 | 79638566 | bellard | register uint32_t EAX asm(AREG4); |
33 | 04369ff2 | bellard | #define reg_EAX
|
34 | 7d13299d | bellard | #endif
|
35 | 79638566 | bellard | |
36 | 79638566 | bellard | #ifdef AREG5
|
37 | 79638566 | bellard | register uint32_t ESP asm(AREG5); |
38 | ae228531 | bellard | #define reg_ESP
|
39 | 79638566 | bellard | #endif
|
40 | 79638566 | bellard | |
41 | 79638566 | bellard | #ifdef AREG6
|
42 | 79638566 | bellard | register uint32_t EBP asm(AREG6); |
43 | ae228531 | bellard | #define reg_EBP
|
44 | 7d13299d | bellard | #endif
|
45 | 79638566 | bellard | |
46 | 79638566 | bellard | #ifdef AREG7
|
47 | 79638566 | bellard | register uint32_t ECX asm(AREG7); |
48 | 79638566 | bellard | #define reg_ECX
|
49 | fb3e5849 | bellard | #endif
|
50 | 79638566 | bellard | |
51 | 79638566 | bellard | #ifdef AREG8
|
52 | 79638566 | bellard | register uint32_t EDX asm(AREG8); |
53 | 79638566 | bellard | #define reg_EDX
|
54 | d03cda59 | bellard | #endif
|
55 | 79638566 | bellard | |
56 | 79638566 | bellard | #ifdef AREG9
|
57 | 79638566 | bellard | register uint32_t EBX asm(AREG9); |
58 | 79638566 | bellard | #define reg_EBX
|
59 | 0d330196 | bellard | #endif
|
60 | 7d13299d | bellard | |
61 | 79638566 | bellard | #ifdef AREG10
|
62 | 79638566 | bellard | register uint32_t ESI asm(AREG10); |
63 | 79638566 | bellard | #define reg_ESI
|
64 | 79638566 | bellard | #endif
|
65 | 7d13299d | bellard | |
66 | 79638566 | bellard | #ifdef AREG11
|
67 | 79638566 | bellard | register uint32_t EDI asm(AREG11); |
68 | 79638566 | bellard | #define reg_EDI
|
69 | 7d13299d | bellard | #endif
|
70 | 7d13299d | bellard | |
71 | 79638566 | bellard | extern FILE *logfile;
|
72 | 79638566 | bellard | extern int loglevel; |
73 | 7d13299d | bellard | |
74 | 04369ff2 | bellard | #ifndef reg_EAX
|
75 | 7d13299d | bellard | #define EAX (env->regs[R_EAX])
|
76 | 04369ff2 | bellard | #endif
|
77 | 04369ff2 | bellard | #ifndef reg_ECX
|
78 | 7d13299d | bellard | #define ECX (env->regs[R_ECX])
|
79 | 04369ff2 | bellard | #endif
|
80 | 04369ff2 | bellard | #ifndef reg_EDX
|
81 | 7d13299d | bellard | #define EDX (env->regs[R_EDX])
|
82 | 04369ff2 | bellard | #endif
|
83 | 04369ff2 | bellard | #ifndef reg_EBX
|
84 | 7d13299d | bellard | #define EBX (env->regs[R_EBX])
|
85 | 04369ff2 | bellard | #endif
|
86 | 04369ff2 | bellard | #ifndef reg_ESP
|
87 | 7d13299d | bellard | #define ESP (env->regs[R_ESP])
|
88 | 04369ff2 | bellard | #endif
|
89 | 04369ff2 | bellard | #ifndef reg_EBP
|
90 | 7d13299d | bellard | #define EBP (env->regs[R_EBP])
|
91 | 04369ff2 | bellard | #endif
|
92 | 04369ff2 | bellard | #ifndef reg_ESI
|
93 | 7d13299d | bellard | #define ESI (env->regs[R_ESI])
|
94 | 04369ff2 | bellard | #endif
|
95 | 04369ff2 | bellard | #ifndef reg_EDI
|
96 | 7d13299d | bellard | #define EDI (env->regs[R_EDI])
|
97 | 04369ff2 | bellard | #endif
|
98 | dab2ed99 | bellard | #define EIP (env->eip)
|
99 | 7d13299d | bellard | #define DF (env->df)
|
100 | 7d13299d | bellard | |
101 | 7d13299d | bellard | #define CC_SRC (env->cc_src)
|
102 | 7d13299d | bellard | #define CC_DST (env->cc_dst)
|
103 | 7d13299d | bellard | #define CC_OP (env->cc_op)
|
104 | 7d13299d | bellard | |
105 | 7d13299d | bellard | /* float macros */
|
106 | 7d13299d | bellard | #define FT0 (env->ft0)
|
107 | 7d13299d | bellard | #define ST0 (env->fpregs[env->fpstt])
|
108 | 7d13299d | bellard | #define ST(n) (env->fpregs[(env->fpstt + (n)) & 7]) |
109 | 7d13299d | bellard | #define ST1 ST(1) |
110 | 7d13299d | bellard | |
111 | d014c98c | bellard | #ifdef USE_FP_CONVERT
|
112 | d014c98c | bellard | #define FP_CONVERT (env->fp_convert)
|
113 | d014c98c | bellard | #endif
|
114 | d014c98c | bellard | |
115 | 7d13299d | bellard | #include "cpu-i386.h" |
116 | d4e8164f | bellard | #include "exec.h" |
117 | 7d13299d | bellard | |
118 | 7d13299d | bellard | typedef struct CCTable { |
119 | 7d13299d | bellard | int (*compute_all)(void); /* return all the flags */ |
120 | 7d13299d | bellard | int (*compute_c)(void); /* return the C flag */ |
121 | 7d13299d | bellard | } CCTable; |
122 | 7d13299d | bellard | |
123 | 7d13299d | bellard | extern CCTable cc_table[];
|
124 | 6dbad63e | bellard | |
125 | a513fe19 | bellard | void load_seg(int seg_reg, int selector, unsigned cur_eip); |
126 | 2c1794c4 | bellard | void helper_ljmp_protected_T0_T1(void); |
127 | 2c1794c4 | bellard | void helper_lcall_real_T0_T1(int shift, int next_eip); |
128 | 2c1794c4 | bellard | void helper_lcall_protected_T0_T1(int shift, int next_eip); |
129 | 2c1794c4 | bellard | void helper_iret_real(int shift); |
130 | 90a9fdae | bellard | void helper_iret_protected(int shift); |
131 | 2c1794c4 | bellard | void helper_lret_protected(int shift, int addend); |
132 | d8bc1fd0 | bellard | void helper_lldt_T0(void); |
133 | d8bc1fd0 | bellard | void helper_ltr_T0(void); |
134 | d8bc1fd0 | bellard | void helper_movl_crN_T0(int reg); |
135 | d8bc1fd0 | bellard | void helper_movl_drN_T0(int reg); |
136 | 90a9fdae | bellard | void helper_invlpg(unsigned int addr); |
137 | 90a9fdae | bellard | void cpu_x86_update_cr0(CPUX86State *env);
|
138 | 90a9fdae | bellard | void cpu_x86_update_cr3(CPUX86State *env);
|
139 | 90a9fdae | bellard | void cpu_x86_flush_tlb(CPUX86State *env, uint32_t addr);
|
140 | 90a9fdae | bellard | int cpu_x86_handle_mmu_fault(CPUX86State *env, uint32_t addr, int is_write); |
141 | 3ec9c4fc | bellard | void __hidden cpu_lock(void); |
142 | 3ec9c4fc | bellard | void __hidden cpu_unlock(void); |
143 | 90a9fdae | bellard | void do_interrupt(int intno, int is_int, int error_code, |
144 | 90a9fdae | bellard | unsigned int next_eip); |
145 | 90a9fdae | bellard | void do_interrupt_user(int intno, int is_int, int error_code, |
146 | 90a9fdae | bellard | unsigned int next_eip); |
147 | a513fe19 | bellard | void raise_interrupt(int intno, int is_int, int error_code, |
148 | a513fe19 | bellard | unsigned int next_eip); |
149 | 455b7619 | bellard | void raise_exception_err(int exception_index, int error_code); |
150 | 9de5e440 | bellard | void raise_exception(int exception_index); |
151 | 3ec9c4fc | bellard | void __hidden cpu_loop_exit(void); |
152 | d0a1ffc9 | bellard | void helper_fsave(uint8_t *ptr, int data32); |
153 | d0a1ffc9 | bellard | void helper_frstor(uint8_t *ptr, int data32); |
154 | 9de5e440 | bellard | |
155 | 9de5e440 | bellard | void OPPROTO op_movl_eflags_T0(void); |
156 | 9de5e440 | bellard | void OPPROTO op_movl_T0_eflags(void); |
157 | 3ec9c4fc | bellard | void raise_interrupt(int intno, int is_int, int error_code, |
158 | 3ec9c4fc | bellard | unsigned int next_eip); |
159 | 3ec9c4fc | bellard | void raise_exception_err(int exception_index, int error_code); |
160 | 3ec9c4fc | bellard | void raise_exception(int exception_index); |
161 | e163bca7 | bellard | void helper_divl_EAX_T0(uint32_t eip);
|
162 | e163bca7 | bellard | void helper_idivl_EAX_T0(uint32_t eip);
|
163 | e163bca7 | bellard | void helper_cmpxchg8b(void); |
164 | 3ec9c4fc | bellard | void helper_cpuid(void); |
165 | e163bca7 | bellard | void helper_rdtsc(void); |
166 | 3c1cf9fa | bellard | void helper_rdmsr(void); |
167 | 3c1cf9fa | bellard | void helper_wrmsr(void); |
168 | 3ec9c4fc | bellard | void helper_lsl(void); |
169 | 3ec9c4fc | bellard | void helper_lar(void); |
170 | 3ec9c4fc | bellard | |
171 | 3ec9c4fc | bellard | #ifdef USE_X86LDOUBLE
|
172 | 3ec9c4fc | bellard | /* use long double functions */
|
173 | 3ec9c4fc | bellard | #define lrint lrintl
|
174 | 3ec9c4fc | bellard | #define llrint llrintl
|
175 | 3ec9c4fc | bellard | #define fabs fabsl
|
176 | 3ec9c4fc | bellard | #define sin sinl
|
177 | 3ec9c4fc | bellard | #define cos cosl
|
178 | 3ec9c4fc | bellard | #define sqrt sqrtl
|
179 | 3ec9c4fc | bellard | #define pow powl
|
180 | 3ec9c4fc | bellard | #define log logl
|
181 | 3ec9c4fc | bellard | #define tan tanl
|
182 | 3ec9c4fc | bellard | #define atan2 atan2l
|
183 | 3ec9c4fc | bellard | #define floor floorl
|
184 | 3ec9c4fc | bellard | #define ceil ceill
|
185 | 3ec9c4fc | bellard | #define rint rintl
|
186 | 3ec9c4fc | bellard | #endif
|
187 | 3ec9c4fc | bellard | |
188 | 3ec9c4fc | bellard | extern int lrint(CPU86_LDouble x); |
189 | 3ec9c4fc | bellard | extern int64_t llrint(CPU86_LDouble x);
|
190 | 3ec9c4fc | bellard | extern CPU86_LDouble fabs(CPU86_LDouble x);
|
191 | 3ec9c4fc | bellard | extern CPU86_LDouble sin(CPU86_LDouble x);
|
192 | 3ec9c4fc | bellard | extern CPU86_LDouble cos(CPU86_LDouble x);
|
193 | 3ec9c4fc | bellard | extern CPU86_LDouble sqrt(CPU86_LDouble x);
|
194 | 3ec9c4fc | bellard | extern CPU86_LDouble pow(CPU86_LDouble, CPU86_LDouble);
|
195 | 3ec9c4fc | bellard | extern CPU86_LDouble log(CPU86_LDouble x);
|
196 | 3ec9c4fc | bellard | extern CPU86_LDouble tan(CPU86_LDouble x);
|
197 | 3ec9c4fc | bellard | extern CPU86_LDouble atan2(CPU86_LDouble, CPU86_LDouble);
|
198 | 3ec9c4fc | bellard | extern CPU86_LDouble floor(CPU86_LDouble x);
|
199 | 3ec9c4fc | bellard | extern CPU86_LDouble ceil(CPU86_LDouble x);
|
200 | 3ec9c4fc | bellard | extern CPU86_LDouble rint(CPU86_LDouble x);
|
201 | 3ec9c4fc | bellard | |
202 | 3ec9c4fc | bellard | #define RC_MASK 0xc00 |
203 | 3ec9c4fc | bellard | #define RC_NEAR 0x000 |
204 | 3ec9c4fc | bellard | #define RC_DOWN 0x400 |
205 | 3ec9c4fc | bellard | #define RC_UP 0x800 |
206 | 3ec9c4fc | bellard | #define RC_CHOP 0xc00 |
207 | 3ec9c4fc | bellard | |
208 | 3ec9c4fc | bellard | #define MAXTAN 9223372036854775808.0 |
209 | 3ec9c4fc | bellard | |
210 | e163bca7 | bellard | #ifdef __arm__
|
211 | e163bca7 | bellard | /* we have no way to do correct rounding - a FPU emulator is needed */
|
212 | e163bca7 | bellard | #define FE_DOWNWARD FE_TONEAREST
|
213 | e163bca7 | bellard | #define FE_UPWARD FE_TONEAREST
|
214 | e163bca7 | bellard | #define FE_TOWARDZERO FE_TONEAREST
|
215 | e163bca7 | bellard | #endif
|
216 | e163bca7 | bellard | |
217 | 3ec9c4fc | bellard | #ifdef USE_X86LDOUBLE
|
218 | 3ec9c4fc | bellard | |
219 | 3ec9c4fc | bellard | /* only for x86 */
|
220 | 3ec9c4fc | bellard | typedef union { |
221 | 3ec9c4fc | bellard | long double d; |
222 | 3ec9c4fc | bellard | struct {
|
223 | 3ec9c4fc | bellard | unsigned long long lower; |
224 | 3ec9c4fc | bellard | unsigned short upper; |
225 | 3ec9c4fc | bellard | } l; |
226 | 3ec9c4fc | bellard | } CPU86_LDoubleU; |
227 | 3ec9c4fc | bellard | |
228 | 3ec9c4fc | bellard | /* the following deal with x86 long double-precision numbers */
|
229 | 3ec9c4fc | bellard | #define MAXEXPD 0x7fff |
230 | 3ec9c4fc | bellard | #define EXPBIAS 16383 |
231 | 3ec9c4fc | bellard | #define EXPD(fp) (fp.l.upper & 0x7fff) |
232 | 3ec9c4fc | bellard | #define SIGND(fp) ((fp.l.upper) & 0x8000) |
233 | 3ec9c4fc | bellard | #define MANTD(fp) (fp.l.lower)
|
234 | 3ec9c4fc | bellard | #define BIASEXPONENT(fp) fp.l.upper = (fp.l.upper & ~(0x7fff)) | EXPBIAS |
235 | 3ec9c4fc | bellard | |
236 | 3ec9c4fc | bellard | #else
|
237 | 3ec9c4fc | bellard | |
238 | e163bca7 | bellard | /* NOTE: arm is horrible as double 32 bit words are stored in big endian ! */
|
239 | 3ec9c4fc | bellard | typedef union { |
240 | 3ec9c4fc | bellard | double d;
|
241 | e163bca7 | bellard | #if !defined(WORDS_BIGENDIAN) && !defined(__arm__)
|
242 | 3ec9c4fc | bellard | struct {
|
243 | 3ec9c4fc | bellard | uint32_t lower; |
244 | 3ec9c4fc | bellard | int32_t upper; |
245 | 3ec9c4fc | bellard | } l; |
246 | 3ec9c4fc | bellard | #else
|
247 | 3ec9c4fc | bellard | struct {
|
248 | 3ec9c4fc | bellard | int32_t upper; |
249 | 3ec9c4fc | bellard | uint32_t lower; |
250 | 3ec9c4fc | bellard | } l; |
251 | 3ec9c4fc | bellard | #endif
|
252 | e163bca7 | bellard | #ifndef __arm__
|
253 | 3ec9c4fc | bellard | int64_t ll; |
254 | e163bca7 | bellard | #endif
|
255 | 3ec9c4fc | bellard | } CPU86_LDoubleU; |
256 | 3ec9c4fc | bellard | |
257 | 3ec9c4fc | bellard | /* the following deal with IEEE double-precision numbers */
|
258 | 3ec9c4fc | bellard | #define MAXEXPD 0x7ff |
259 | 3ec9c4fc | bellard | #define EXPBIAS 1023 |
260 | 3ec9c4fc | bellard | #define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF) |
261 | 3ec9c4fc | bellard | #define SIGND(fp) ((fp.l.upper) & 0x80000000) |
262 | e163bca7 | bellard | #ifdef __arm__
|
263 | e163bca7 | bellard | #define MANTD(fp) (fp.l.lower | ((uint64_t)(fp.l.upper & ((1 << 20) - 1)) << 32)) |
264 | e163bca7 | bellard | #else
|
265 | 3ec9c4fc | bellard | #define MANTD(fp) (fp.ll & ((1LL << 52) - 1)) |
266 | e163bca7 | bellard | #endif
|
267 | 3ec9c4fc | bellard | #define BIASEXPONENT(fp) fp.l.upper = (fp.l.upper & ~(0x7ff << 20)) | (EXPBIAS << 20) |
268 | 3ec9c4fc | bellard | #endif
|
269 | 3ec9c4fc | bellard | |
270 | 3ec9c4fc | bellard | static inline void fpush(void) |
271 | 3ec9c4fc | bellard | { |
272 | 3ec9c4fc | bellard | env->fpstt = (env->fpstt - 1) & 7; |
273 | 3ec9c4fc | bellard | env->fptags[env->fpstt] = 0; /* validate stack entry */ |
274 | 3ec9c4fc | bellard | } |
275 | 3ec9c4fc | bellard | |
276 | 3ec9c4fc | bellard | static inline void fpop(void) |
277 | 3ec9c4fc | bellard | { |
278 | 3ec9c4fc | bellard | env->fptags[env->fpstt] = 1; /* invvalidate stack entry */ |
279 | 3ec9c4fc | bellard | env->fpstt = (env->fpstt + 1) & 7; |
280 | 3ec9c4fc | bellard | } |
281 | 3ec9c4fc | bellard | |
282 | 3ec9c4fc | bellard | #ifndef USE_X86LDOUBLE
|
283 | 3ec9c4fc | bellard | static inline CPU86_LDouble helper_fldt(uint8_t *ptr) |
284 | 3ec9c4fc | bellard | { |
285 | 3ec9c4fc | bellard | CPU86_LDoubleU temp; |
286 | 3ec9c4fc | bellard | int upper, e;
|
287 | e163bca7 | bellard | uint64_t ll; |
288 | e163bca7 | bellard | |
289 | 3ec9c4fc | bellard | /* mantissa */
|
290 | 3ec9c4fc | bellard | upper = lduw(ptr + 8);
|
291 | 3ec9c4fc | bellard | /* XXX: handle overflow ? */
|
292 | 3ec9c4fc | bellard | e = (upper & 0x7fff) - 16383 + EXPBIAS; /* exponent */ |
293 | 3ec9c4fc | bellard | e |= (upper >> 4) & 0x800; /* sign */ |
294 | e163bca7 | bellard | ll = (ldq(ptr) >> 11) & ((1LL << 52) - 1); |
295 | e163bca7 | bellard | #ifdef __arm__
|
296 | e163bca7 | bellard | temp.l.upper = (e << 20) | (ll >> 32); |
297 | e163bca7 | bellard | temp.l.lower = ll; |
298 | e163bca7 | bellard | #else
|
299 | e163bca7 | bellard | temp.ll = ll | ((uint64_t)e << 52);
|
300 | e163bca7 | bellard | #endif
|
301 | 3ec9c4fc | bellard | return temp.d;
|
302 | 3ec9c4fc | bellard | } |
303 | 3ec9c4fc | bellard | |
304 | 3ec9c4fc | bellard | static inline void helper_fstt(CPU86_LDouble f, uint8_t *ptr) |
305 | 3ec9c4fc | bellard | { |
306 | 3ec9c4fc | bellard | CPU86_LDoubleU temp; |
307 | 3ec9c4fc | bellard | int e;
|
308 | e163bca7 | bellard | |
309 | 3ec9c4fc | bellard | temp.d = f; |
310 | 3ec9c4fc | bellard | /* mantissa */
|
311 | 3ec9c4fc | bellard | stq(ptr, (MANTD(temp) << 11) | (1LL << 63)); |
312 | 3ec9c4fc | bellard | /* exponent + sign */
|
313 | 3ec9c4fc | bellard | e = EXPD(temp) - EXPBIAS + 16383;
|
314 | 3ec9c4fc | bellard | e |= SIGND(temp) >> 16;
|
315 | 3ec9c4fc | bellard | stw(ptr + 8, e);
|
316 | 3ec9c4fc | bellard | } |
317 | 3ec9c4fc | bellard | #endif
|
318 | 3ec9c4fc | bellard | |
319 | e163bca7 | bellard | const CPU86_LDouble f15rk[7]; |
320 | e163bca7 | bellard | |
321 | 3ec9c4fc | bellard | void helper_fldt_ST0_A0(void); |
322 | 3ec9c4fc | bellard | void helper_fstt_ST0_A0(void); |
323 | 3ec9c4fc | bellard | void helper_fbld_ST0_A0(void); |
324 | 3ec9c4fc | bellard | void helper_fbst_ST0_A0(void); |
325 | 3ec9c4fc | bellard | void helper_f2xm1(void); |
326 | 3ec9c4fc | bellard | void helper_fyl2x(void); |
327 | 3ec9c4fc | bellard | void helper_fptan(void); |
328 | 3ec9c4fc | bellard | void helper_fpatan(void); |
329 | 3ec9c4fc | bellard | void helper_fxtract(void); |
330 | 3ec9c4fc | bellard | void helper_fprem1(void); |
331 | 3ec9c4fc | bellard | void helper_fprem(void); |
332 | 3ec9c4fc | bellard | void helper_fyl2xp1(void); |
333 | 3ec9c4fc | bellard | void helper_fsqrt(void); |
334 | 3ec9c4fc | bellard | void helper_fsincos(void); |
335 | 3ec9c4fc | bellard | void helper_frndint(void); |
336 | 3ec9c4fc | bellard | void helper_fscale(void); |
337 | 3ec9c4fc | bellard | void helper_fsin(void); |
338 | 3ec9c4fc | bellard | void helper_fcos(void); |
339 | 3ec9c4fc | bellard | void helper_fxam_ST0(void); |
340 | 3ec9c4fc | bellard | void helper_fstenv(uint8_t *ptr, int data32); |
341 | 3ec9c4fc | bellard | void helper_fldenv(uint8_t *ptr, int data32); |
342 | 3ec9c4fc | bellard | void helper_fsave(uint8_t *ptr, int data32); |
343 | 3ec9c4fc | bellard | void helper_frstor(uint8_t *ptr, int data32); |
344 | 3ec9c4fc | bellard | |
345 | 79638566 | bellard | const uint8_t parity_table[256]; |
346 | 79638566 | bellard | const uint8_t rclw_table[32]; |
347 | 79638566 | bellard | const uint8_t rclb_table[32]; |
348 | 90a9fdae | bellard | |
349 | 90a9fdae | bellard | static inline uint32_t compute_eflags(void) |
350 | 90a9fdae | bellard | { |
351 | 90a9fdae | bellard | return env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
|
352 | 90a9fdae | bellard | } |
353 | 90a9fdae | bellard | |
354 | 90a9fdae | bellard | #define FL_UPDATE_MASK32 (TF_MASK | AC_MASK | ID_MASK)
|
355 | 90a9fdae | bellard | |
356 | 90a9fdae | bellard | #define FL_UPDATE_CPL0_MASK (TF_MASK | IF_MASK | IOPL_MASK | NT_MASK | \
|
357 | 90a9fdae | bellard | RF_MASK | AC_MASK | ID_MASK) |
358 | 90a9fdae | bellard | |
359 | 90a9fdae | bellard | /* NOTE: CC_OP must be modified manually to CC_OP_EFLAGS */
|
360 | 90a9fdae | bellard | static inline void load_eflags(int eflags, int update_mask) |
361 | 90a9fdae | bellard | { |
362 | 90a9fdae | bellard | CC_SRC = eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); |
363 | 90a9fdae | bellard | DF = 1 - (2 * ((eflags >> 10) & 1)); |
364 | 90a9fdae | bellard | env->eflags = (env->eflags & ~update_mask) | |
365 | 90a9fdae | bellard | (eflags & update_mask); |
366 | 90a9fdae | bellard | } |