root / target-i386 / op.c @ 0e4b179d
History | View | Annotate | Download (35.5 kB)
1 |
/*
|
---|---|
2 |
* i386 micro operations
|
3 |
*
|
4 |
* Copyright (c) 2003 Fabrice Bellard
|
5 |
*
|
6 |
* This library is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU Lesser General Public
|
8 |
* License as published by the Free Software Foundation; either
|
9 |
* version 2 of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This library 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 GNU
|
14 |
* Lesser General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU Lesser General Public
|
17 |
* License along with this library; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 |
*/
|
20 |
|
21 |
/* XXX: must use this define because the soft mmu macros have huge
|
22 |
register constraints so they cannot be used in any C code. gcc 3.3
|
23 |
does not seem to be able to handle some constraints in rol
|
24 |
operations, so we disable it. */
|
25 |
#if !(__GNUC__ == 3 && __GNUC_MINOR__ == 3) |
26 |
#define ASM_SOFTMMU
|
27 |
#endif
|
28 |
#include "exec.h" |
29 |
|
30 |
/* n must be a constant to be efficient */
|
31 |
static inline int lshift(int x, int n) |
32 |
{ |
33 |
if (n >= 0) |
34 |
return x << n;
|
35 |
else
|
36 |
return x >> (-n);
|
37 |
} |
38 |
|
39 |
/* we define the various pieces of code used by the JIT */
|
40 |
|
41 |
#define REG EAX
|
42 |
#define REGNAME _EAX
|
43 |
#include "opreg_template.h" |
44 |
#undef REG
|
45 |
#undef REGNAME
|
46 |
|
47 |
#define REG ECX
|
48 |
#define REGNAME _ECX
|
49 |
#include "opreg_template.h" |
50 |
#undef REG
|
51 |
#undef REGNAME
|
52 |
|
53 |
#define REG EDX
|
54 |
#define REGNAME _EDX
|
55 |
#include "opreg_template.h" |
56 |
#undef REG
|
57 |
#undef REGNAME
|
58 |
|
59 |
#define REG EBX
|
60 |
#define REGNAME _EBX
|
61 |
#include "opreg_template.h" |
62 |
#undef REG
|
63 |
#undef REGNAME
|
64 |
|
65 |
#define REG ESP
|
66 |
#define REGNAME _ESP
|
67 |
#include "opreg_template.h" |
68 |
#undef REG
|
69 |
#undef REGNAME
|
70 |
|
71 |
#define REG EBP
|
72 |
#define REGNAME _EBP
|
73 |
#include "opreg_template.h" |
74 |
#undef REG
|
75 |
#undef REGNAME
|
76 |
|
77 |
#define REG ESI
|
78 |
#define REGNAME _ESI
|
79 |
#include "opreg_template.h" |
80 |
#undef REG
|
81 |
#undef REGNAME
|
82 |
|
83 |
#define REG EDI
|
84 |
#define REGNAME _EDI
|
85 |
#include "opreg_template.h" |
86 |
#undef REG
|
87 |
#undef REGNAME
|
88 |
|
89 |
/* operations with flags */
|
90 |
|
91 |
/* update flags with T0 and T1 (add/sub case) */
|
92 |
void OPPROTO op_update2_cc(void) |
93 |
{ |
94 |
CC_SRC = T1; |
95 |
CC_DST = T0; |
96 |
} |
97 |
|
98 |
/* update flags with T0 (logic operation case) */
|
99 |
void OPPROTO op_update1_cc(void) |
100 |
{ |
101 |
CC_DST = T0; |
102 |
} |
103 |
|
104 |
void OPPROTO op_update_neg_cc(void) |
105 |
{ |
106 |
CC_SRC = -T0; |
107 |
CC_DST = T0; |
108 |
} |
109 |
|
110 |
void OPPROTO op_cmpl_T0_T1_cc(void) |
111 |
{ |
112 |
CC_SRC = T1; |
113 |
CC_DST = T0 - T1; |
114 |
} |
115 |
|
116 |
void OPPROTO op_update_inc_cc(void) |
117 |
{ |
118 |
CC_SRC = cc_table[CC_OP].compute_c(); |
119 |
CC_DST = T0; |
120 |
} |
121 |
|
122 |
void OPPROTO op_testl_T0_T1_cc(void) |
123 |
{ |
124 |
CC_DST = T0 & T1; |
125 |
} |
126 |
|
127 |
/* operations without flags */
|
128 |
|
129 |
void OPPROTO op_addl_T0_T1(void) |
130 |
{ |
131 |
T0 += T1; |
132 |
} |
133 |
|
134 |
void OPPROTO op_orl_T0_T1(void) |
135 |
{ |
136 |
T0 |= T1; |
137 |
} |
138 |
|
139 |
void OPPROTO op_andl_T0_T1(void) |
140 |
{ |
141 |
T0 &= T1; |
142 |
} |
143 |
|
144 |
void OPPROTO op_subl_T0_T1(void) |
145 |
{ |
146 |
T0 -= T1; |
147 |
} |
148 |
|
149 |
void OPPROTO op_xorl_T0_T1(void) |
150 |
{ |
151 |
T0 ^= T1; |
152 |
} |
153 |
|
154 |
void OPPROTO op_negl_T0(void) |
155 |
{ |
156 |
T0 = -T0; |
157 |
} |
158 |
|
159 |
void OPPROTO op_incl_T0(void) |
160 |
{ |
161 |
T0++; |
162 |
} |
163 |
|
164 |
void OPPROTO op_decl_T0(void) |
165 |
{ |
166 |
T0--; |
167 |
} |
168 |
|
169 |
void OPPROTO op_notl_T0(void) |
170 |
{ |
171 |
T0 = ~T0; |
172 |
} |
173 |
|
174 |
void OPPROTO op_bswapl_T0(void) |
175 |
{ |
176 |
T0 = bswap32(T0); |
177 |
} |
178 |
|
179 |
/* multiply/divide */
|
180 |
|
181 |
/* XXX: add eflags optimizations */
|
182 |
/* XXX: add non P4 style flags */
|
183 |
|
184 |
void OPPROTO op_mulb_AL_T0(void) |
185 |
{ |
186 |
unsigned int res; |
187 |
res = (uint8_t)EAX * (uint8_t)T0; |
188 |
EAX = (EAX & 0xffff0000) | res;
|
189 |
CC_DST = res; |
190 |
CC_SRC = (res & 0xff00);
|
191 |
} |
192 |
|
193 |
void OPPROTO op_imulb_AL_T0(void) |
194 |
{ |
195 |
int res;
|
196 |
res = (int8_t)EAX * (int8_t)T0; |
197 |
EAX = (EAX & 0xffff0000) | (res & 0xffff); |
198 |
CC_DST = res; |
199 |
CC_SRC = (res != (int8_t)res); |
200 |
} |
201 |
|
202 |
void OPPROTO op_mulw_AX_T0(void) |
203 |
{ |
204 |
unsigned int res; |
205 |
res = (uint16_t)EAX * (uint16_t)T0; |
206 |
EAX = (EAX & 0xffff0000) | (res & 0xffff); |
207 |
EDX = (EDX & 0xffff0000) | ((res >> 16) & 0xffff); |
208 |
CC_DST = res; |
209 |
CC_SRC = res >> 16;
|
210 |
} |
211 |
|
212 |
void OPPROTO op_imulw_AX_T0(void) |
213 |
{ |
214 |
int res;
|
215 |
res = (int16_t)EAX * (int16_t)T0; |
216 |
EAX = (EAX & 0xffff0000) | (res & 0xffff); |
217 |
EDX = (EDX & 0xffff0000) | ((res >> 16) & 0xffff); |
218 |
CC_DST = res; |
219 |
CC_SRC = (res != (int16_t)res); |
220 |
} |
221 |
|
222 |
void OPPROTO op_mull_EAX_T0(void) |
223 |
{ |
224 |
uint64_t res; |
225 |
res = (uint64_t)((uint32_t)EAX) * (uint64_t)((uint32_t)T0); |
226 |
EAX = res; |
227 |
EDX = res >> 32;
|
228 |
CC_DST = res; |
229 |
CC_SRC = res >> 32;
|
230 |
} |
231 |
|
232 |
void OPPROTO op_imull_EAX_T0(void) |
233 |
{ |
234 |
int64_t res; |
235 |
res = (int64_t)((int32_t)EAX) * (int64_t)((int32_t)T0); |
236 |
EAX = res; |
237 |
EDX = res >> 32;
|
238 |
CC_DST = res; |
239 |
CC_SRC = (res != (int32_t)res); |
240 |
} |
241 |
|
242 |
void OPPROTO op_imulw_T0_T1(void) |
243 |
{ |
244 |
int res;
|
245 |
res = (int16_t)T0 * (int16_t)T1; |
246 |
T0 = res; |
247 |
CC_DST = res; |
248 |
CC_SRC = (res != (int16_t)res); |
249 |
} |
250 |
|
251 |
void OPPROTO op_imull_T0_T1(void) |
252 |
{ |
253 |
int64_t res; |
254 |
res = (int64_t)((int32_t)T0) * (int64_t)((int32_t)T1); |
255 |
T0 = res; |
256 |
CC_DST = res; |
257 |
CC_SRC = (res != (int32_t)res); |
258 |
} |
259 |
|
260 |
/* division, flags are undefined */
|
261 |
/* XXX: add exceptions for overflow */
|
262 |
|
263 |
void OPPROTO op_divb_AL_T0(void) |
264 |
{ |
265 |
unsigned int num, den, q, r; |
266 |
|
267 |
num = (EAX & 0xffff);
|
268 |
den = (T0 & 0xff);
|
269 |
if (den == 0) { |
270 |
EIP = PARAM1; |
271 |
raise_exception(EXCP00_DIVZ); |
272 |
} |
273 |
q = (num / den) & 0xff;
|
274 |
r = (num % den) & 0xff;
|
275 |
EAX = (EAX & 0xffff0000) | (r << 8) | q; |
276 |
} |
277 |
|
278 |
void OPPROTO op_idivb_AL_T0(void) |
279 |
{ |
280 |
int num, den, q, r;
|
281 |
|
282 |
num = (int16_t)EAX; |
283 |
den = (int8_t)T0; |
284 |
if (den == 0) { |
285 |
EIP = PARAM1; |
286 |
raise_exception(EXCP00_DIVZ); |
287 |
} |
288 |
q = (num / den) & 0xff;
|
289 |
r = (num % den) & 0xff;
|
290 |
EAX = (EAX & 0xffff0000) | (r << 8) | q; |
291 |
} |
292 |
|
293 |
void OPPROTO op_divw_AX_T0(void) |
294 |
{ |
295 |
unsigned int num, den, q, r; |
296 |
|
297 |
num = (EAX & 0xffff) | ((EDX & 0xffff) << 16); |
298 |
den = (T0 & 0xffff);
|
299 |
if (den == 0) { |
300 |
EIP = PARAM1; |
301 |
raise_exception(EXCP00_DIVZ); |
302 |
} |
303 |
q = (num / den) & 0xffff;
|
304 |
r = (num % den) & 0xffff;
|
305 |
EAX = (EAX & 0xffff0000) | q;
|
306 |
EDX = (EDX & 0xffff0000) | r;
|
307 |
} |
308 |
|
309 |
void OPPROTO op_idivw_AX_T0(void) |
310 |
{ |
311 |
int num, den, q, r;
|
312 |
|
313 |
num = (EAX & 0xffff) | ((EDX & 0xffff) << 16); |
314 |
den = (int16_t)T0; |
315 |
if (den == 0) { |
316 |
EIP = PARAM1; |
317 |
raise_exception(EXCP00_DIVZ); |
318 |
} |
319 |
q = (num / den) & 0xffff;
|
320 |
r = (num % den) & 0xffff;
|
321 |
EAX = (EAX & 0xffff0000) | q;
|
322 |
EDX = (EDX & 0xffff0000) | r;
|
323 |
} |
324 |
|
325 |
void OPPROTO op_divl_EAX_T0(void) |
326 |
{ |
327 |
helper_divl_EAX_T0(PARAM1); |
328 |
} |
329 |
|
330 |
void OPPROTO op_idivl_EAX_T0(void) |
331 |
{ |
332 |
helper_idivl_EAX_T0(PARAM1); |
333 |
} |
334 |
|
335 |
/* constant load & misc op */
|
336 |
|
337 |
void OPPROTO op_movl_T0_im(void) |
338 |
{ |
339 |
T0 = PARAM1; |
340 |
} |
341 |
|
342 |
void OPPROTO op_addl_T0_im(void) |
343 |
{ |
344 |
T0 += PARAM1; |
345 |
} |
346 |
|
347 |
void OPPROTO op_andl_T0_ffff(void) |
348 |
{ |
349 |
T0 = T0 & 0xffff;
|
350 |
} |
351 |
|
352 |
void OPPROTO op_andl_T0_im(void) |
353 |
{ |
354 |
T0 = T0 & PARAM1; |
355 |
} |
356 |
|
357 |
void OPPROTO op_movl_T0_T1(void) |
358 |
{ |
359 |
T0 = T1; |
360 |
} |
361 |
|
362 |
void OPPROTO op_movl_T1_im(void) |
363 |
{ |
364 |
T1 = PARAM1; |
365 |
} |
366 |
|
367 |
void OPPROTO op_addl_T1_im(void) |
368 |
{ |
369 |
T1 += PARAM1; |
370 |
} |
371 |
|
372 |
void OPPROTO op_movl_T1_A0(void) |
373 |
{ |
374 |
T1 = A0; |
375 |
} |
376 |
|
377 |
void OPPROTO op_movl_A0_im(void) |
378 |
{ |
379 |
A0 = PARAM1; |
380 |
} |
381 |
|
382 |
void OPPROTO op_addl_A0_im(void) |
383 |
{ |
384 |
A0 += PARAM1; |
385 |
} |
386 |
|
387 |
void OPPROTO op_addl_A0_AL(void) |
388 |
{ |
389 |
A0 += (EAX & 0xff);
|
390 |
} |
391 |
|
392 |
void OPPROTO op_andl_A0_ffff(void) |
393 |
{ |
394 |
A0 = A0 & 0xffff;
|
395 |
} |
396 |
|
397 |
/* memory access */
|
398 |
|
399 |
#define MEMSUFFIX _raw
|
400 |
#include "ops_mem.h" |
401 |
|
402 |
#if !defined(CONFIG_USER_ONLY)
|
403 |
#define MEMSUFFIX _kernel
|
404 |
#include "ops_mem.h" |
405 |
|
406 |
#define MEMSUFFIX _user
|
407 |
#include "ops_mem.h" |
408 |
#endif
|
409 |
|
410 |
/* used for bit operations */
|
411 |
|
412 |
void OPPROTO op_add_bitw_A0_T1(void) |
413 |
{ |
414 |
A0 += ((int16_t)T1 >> 4) << 1; |
415 |
} |
416 |
|
417 |
void OPPROTO op_add_bitl_A0_T1(void) |
418 |
{ |
419 |
A0 += ((int32_t)T1 >> 5) << 2; |
420 |
} |
421 |
|
422 |
/* indirect jump */
|
423 |
|
424 |
void OPPROTO op_jmp_T0(void) |
425 |
{ |
426 |
EIP = T0; |
427 |
} |
428 |
|
429 |
void OPPROTO op_jmp_im(void) |
430 |
{ |
431 |
EIP = PARAM1; |
432 |
} |
433 |
|
434 |
void OPPROTO op_hlt(void) |
435 |
{ |
436 |
env->exception_index = EXCP_HLT; |
437 |
cpu_loop_exit(); |
438 |
} |
439 |
|
440 |
void OPPROTO op_debug(void) |
441 |
{ |
442 |
env->exception_index = EXCP_DEBUG; |
443 |
cpu_loop_exit(); |
444 |
} |
445 |
|
446 |
void OPPROTO op_raise_interrupt(void) |
447 |
{ |
448 |
int intno;
|
449 |
unsigned int next_eip; |
450 |
intno = PARAM1; |
451 |
next_eip = PARAM2; |
452 |
raise_interrupt(intno, 1, 0, next_eip); |
453 |
} |
454 |
|
455 |
void OPPROTO op_raise_exception(void) |
456 |
{ |
457 |
int exception_index;
|
458 |
exception_index = PARAM1; |
459 |
raise_exception(exception_index); |
460 |
} |
461 |
|
462 |
void OPPROTO op_into(void) |
463 |
{ |
464 |
int eflags;
|
465 |
eflags = cc_table[CC_OP].compute_all(); |
466 |
if (eflags & CC_O) {
|
467 |
raise_interrupt(EXCP04_INTO, 1, 0, PARAM1); |
468 |
} |
469 |
FORCE_RET(); |
470 |
} |
471 |
|
472 |
void OPPROTO op_cli(void) |
473 |
{ |
474 |
env->eflags &= ~IF_MASK; |
475 |
} |
476 |
|
477 |
void OPPROTO op_sti(void) |
478 |
{ |
479 |
env->eflags |= IF_MASK; |
480 |
} |
481 |
|
482 |
void OPPROTO op_set_inhibit_irq(void) |
483 |
{ |
484 |
env->hflags |= HF_INHIBIT_IRQ_MASK; |
485 |
} |
486 |
|
487 |
void OPPROTO op_reset_inhibit_irq(void) |
488 |
{ |
489 |
env->hflags &= ~HF_INHIBIT_IRQ_MASK; |
490 |
} |
491 |
|
492 |
#if 0
|
493 |
/* vm86plus instructions */
|
494 |
void OPPROTO op_cli_vm(void)
|
495 |
{
|
496 |
env->eflags &= ~VIF_MASK;
|
497 |
}
|
498 |
|
499 |
void OPPROTO op_sti_vm(void)
|
500 |
{
|
501 |
env->eflags |= VIF_MASK;
|
502 |
if (env->eflags & VIP_MASK) {
|
503 |
EIP = PARAM1;
|
504 |
raise_exception(EXCP0D_GPF);
|
505 |
}
|
506 |
FORCE_RET();
|
507 |
}
|
508 |
#endif
|
509 |
|
510 |
void OPPROTO op_boundw(void) |
511 |
{ |
512 |
int low, high, v;
|
513 |
low = ldsw((uint8_t *)A0); |
514 |
high = ldsw((uint8_t *)A0 + 2);
|
515 |
v = (int16_t)T0; |
516 |
if (v < low || v > high) {
|
517 |
EIP = PARAM1; |
518 |
raise_exception(EXCP05_BOUND); |
519 |
} |
520 |
FORCE_RET(); |
521 |
} |
522 |
|
523 |
void OPPROTO op_boundl(void) |
524 |
{ |
525 |
int low, high, v;
|
526 |
low = ldl((uint8_t *)A0); |
527 |
high = ldl((uint8_t *)A0 + 4);
|
528 |
v = T0; |
529 |
if (v < low || v > high) {
|
530 |
EIP = PARAM1; |
531 |
raise_exception(EXCP05_BOUND); |
532 |
} |
533 |
FORCE_RET(); |
534 |
} |
535 |
|
536 |
void OPPROTO op_cmpxchg8b(void) |
537 |
{ |
538 |
helper_cmpxchg8b(); |
539 |
} |
540 |
|
541 |
void OPPROTO op_jmp(void) |
542 |
{ |
543 |
JUMP_TB(op_jmp, PARAM1, 0, PARAM2);
|
544 |
} |
545 |
|
546 |
void OPPROTO op_movl_T0_0(void) |
547 |
{ |
548 |
T0 = 0;
|
549 |
} |
550 |
|
551 |
void OPPROTO op_exit_tb(void) |
552 |
{ |
553 |
EXIT_TB(); |
554 |
} |
555 |
|
556 |
/* multiple size ops */
|
557 |
|
558 |
#define ldul ldl
|
559 |
|
560 |
#define SHIFT 0 |
561 |
#include "ops_template.h" |
562 |
#undef SHIFT
|
563 |
|
564 |
#define SHIFT 1 |
565 |
#include "ops_template.h" |
566 |
#undef SHIFT
|
567 |
|
568 |
#define SHIFT 2 |
569 |
#include "ops_template.h" |
570 |
#undef SHIFT
|
571 |
|
572 |
/* sign extend */
|
573 |
|
574 |
void OPPROTO op_movsbl_T0_T0(void) |
575 |
{ |
576 |
T0 = (int8_t)T0; |
577 |
} |
578 |
|
579 |
void OPPROTO op_movzbl_T0_T0(void) |
580 |
{ |
581 |
T0 = (uint8_t)T0; |
582 |
} |
583 |
|
584 |
void OPPROTO op_movswl_T0_T0(void) |
585 |
{ |
586 |
T0 = (int16_t)T0; |
587 |
} |
588 |
|
589 |
void OPPROTO op_movzwl_T0_T0(void) |
590 |
{ |
591 |
T0 = (uint16_t)T0; |
592 |
} |
593 |
|
594 |
void OPPROTO op_movswl_EAX_AX(void) |
595 |
{ |
596 |
EAX = (int16_t)EAX; |
597 |
} |
598 |
|
599 |
void OPPROTO op_movsbw_AX_AL(void) |
600 |
{ |
601 |
EAX = (EAX & 0xffff0000) | ((int8_t)EAX & 0xffff); |
602 |
} |
603 |
|
604 |
void OPPROTO op_movslq_EDX_EAX(void) |
605 |
{ |
606 |
EDX = (int32_t)EAX >> 31;
|
607 |
} |
608 |
|
609 |
void OPPROTO op_movswl_DX_AX(void) |
610 |
{ |
611 |
EDX = (EDX & 0xffff0000) | (((int16_t)EAX >> 15) & 0xffff); |
612 |
} |
613 |
|
614 |
/* string ops helpers */
|
615 |
|
616 |
void OPPROTO op_addl_ESI_T0(void) |
617 |
{ |
618 |
ESI += T0; |
619 |
} |
620 |
|
621 |
void OPPROTO op_addw_ESI_T0(void) |
622 |
{ |
623 |
ESI = (ESI & ~0xffff) | ((ESI + T0) & 0xffff); |
624 |
} |
625 |
|
626 |
void OPPROTO op_addl_EDI_T0(void) |
627 |
{ |
628 |
EDI += T0; |
629 |
} |
630 |
|
631 |
void OPPROTO op_addw_EDI_T0(void) |
632 |
{ |
633 |
EDI = (EDI & ~0xffff) | ((EDI + T0) & 0xffff); |
634 |
} |
635 |
|
636 |
void OPPROTO op_decl_ECX(void) |
637 |
{ |
638 |
ECX--; |
639 |
} |
640 |
|
641 |
void OPPROTO op_decw_ECX(void) |
642 |
{ |
643 |
ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff); |
644 |
} |
645 |
|
646 |
/* push/pop utils */
|
647 |
|
648 |
void op_addl_A0_SS(void) |
649 |
{ |
650 |
A0 += (long)env->segs[R_SS].base;
|
651 |
} |
652 |
|
653 |
void op_subl_A0_2(void) |
654 |
{ |
655 |
A0 -= 2;
|
656 |
} |
657 |
|
658 |
void op_subl_A0_4(void) |
659 |
{ |
660 |
A0 -= 4;
|
661 |
} |
662 |
|
663 |
void op_addl_ESP_4(void) |
664 |
{ |
665 |
ESP += 4;
|
666 |
} |
667 |
|
668 |
void op_addl_ESP_2(void) |
669 |
{ |
670 |
ESP += 2;
|
671 |
} |
672 |
|
673 |
void op_addw_ESP_4(void) |
674 |
{ |
675 |
ESP = (ESP & ~0xffff) | ((ESP + 4) & 0xffff); |
676 |
} |
677 |
|
678 |
void op_addw_ESP_2(void) |
679 |
{ |
680 |
ESP = (ESP & ~0xffff) | ((ESP + 2) & 0xffff); |
681 |
} |
682 |
|
683 |
void op_addl_ESP_im(void) |
684 |
{ |
685 |
ESP += PARAM1; |
686 |
} |
687 |
|
688 |
void op_addw_ESP_im(void) |
689 |
{ |
690 |
ESP = (ESP & ~0xffff) | ((ESP + PARAM1) & 0xffff); |
691 |
} |
692 |
|
693 |
void OPPROTO op_rdtsc(void) |
694 |
{ |
695 |
helper_rdtsc(); |
696 |
} |
697 |
|
698 |
void OPPROTO op_cpuid(void) |
699 |
{ |
700 |
helper_cpuid(); |
701 |
} |
702 |
|
703 |
void OPPROTO op_rdmsr(void) |
704 |
{ |
705 |
helper_rdmsr(); |
706 |
} |
707 |
|
708 |
void OPPROTO op_wrmsr(void) |
709 |
{ |
710 |
helper_wrmsr(); |
711 |
} |
712 |
|
713 |
/* bcd */
|
714 |
|
715 |
/* XXX: exception */
|
716 |
void OPPROTO op_aam(void) |
717 |
{ |
718 |
int base = PARAM1;
|
719 |
int al, ah;
|
720 |
al = EAX & 0xff;
|
721 |
ah = al / base; |
722 |
al = al % base; |
723 |
EAX = (EAX & ~0xffff) | al | (ah << 8); |
724 |
CC_DST = al; |
725 |
} |
726 |
|
727 |
void OPPROTO op_aad(void) |
728 |
{ |
729 |
int base = PARAM1;
|
730 |
int al, ah;
|
731 |
al = EAX & 0xff;
|
732 |
ah = (EAX >> 8) & 0xff; |
733 |
al = ((ah * base) + al) & 0xff;
|
734 |
EAX = (EAX & ~0xffff) | al;
|
735 |
CC_DST = al; |
736 |
} |
737 |
|
738 |
void OPPROTO op_aaa(void) |
739 |
{ |
740 |
int icarry;
|
741 |
int al, ah, af;
|
742 |
int eflags;
|
743 |
|
744 |
eflags = cc_table[CC_OP].compute_all(); |
745 |
af = eflags & CC_A; |
746 |
al = EAX & 0xff;
|
747 |
ah = (EAX >> 8) & 0xff; |
748 |
|
749 |
icarry = (al > 0xf9);
|
750 |
if (((al & 0x0f) > 9 ) || af) { |
751 |
al = (al + 6) & 0x0f; |
752 |
ah = (ah + 1 + icarry) & 0xff; |
753 |
eflags |= CC_C | CC_A; |
754 |
} else {
|
755 |
eflags &= ~(CC_C | CC_A); |
756 |
al &= 0x0f;
|
757 |
} |
758 |
EAX = (EAX & ~0xffff) | al | (ah << 8); |
759 |
CC_SRC = eflags; |
760 |
} |
761 |
|
762 |
void OPPROTO op_aas(void) |
763 |
{ |
764 |
int icarry;
|
765 |
int al, ah, af;
|
766 |
int eflags;
|
767 |
|
768 |
eflags = cc_table[CC_OP].compute_all(); |
769 |
af = eflags & CC_A; |
770 |
al = EAX & 0xff;
|
771 |
ah = (EAX >> 8) & 0xff; |
772 |
|
773 |
icarry = (al < 6);
|
774 |
if (((al & 0x0f) > 9 ) || af) { |
775 |
al = (al - 6) & 0x0f; |
776 |
ah = (ah - 1 - icarry) & 0xff; |
777 |
eflags |= CC_C | CC_A; |
778 |
} else {
|
779 |
eflags &= ~(CC_C | CC_A); |
780 |
al &= 0x0f;
|
781 |
} |
782 |
EAX = (EAX & ~0xffff) | al | (ah << 8); |
783 |
CC_SRC = eflags; |
784 |
} |
785 |
|
786 |
void OPPROTO op_daa(void) |
787 |
{ |
788 |
int al, af, cf;
|
789 |
int eflags;
|
790 |
|
791 |
eflags = cc_table[CC_OP].compute_all(); |
792 |
cf = eflags & CC_C; |
793 |
af = eflags & CC_A; |
794 |
al = EAX & 0xff;
|
795 |
|
796 |
eflags = 0;
|
797 |
if (((al & 0x0f) > 9 ) || af) { |
798 |
al = (al + 6) & 0xff; |
799 |
eflags |= CC_A; |
800 |
} |
801 |
if ((al > 0x9f) || cf) { |
802 |
al = (al + 0x60) & 0xff; |
803 |
eflags |= CC_C; |
804 |
} |
805 |
EAX = (EAX & ~0xff) | al;
|
806 |
/* well, speed is not an issue here, so we compute the flags by hand */
|
807 |
eflags |= (al == 0) << 6; /* zf */ |
808 |
eflags |= parity_table[al]; /* pf */
|
809 |
eflags |= (al & 0x80); /* sf */ |
810 |
CC_SRC = eflags; |
811 |
} |
812 |
|
813 |
void OPPROTO op_das(void) |
814 |
{ |
815 |
int al, al1, af, cf;
|
816 |
int eflags;
|
817 |
|
818 |
eflags = cc_table[CC_OP].compute_all(); |
819 |
cf = eflags & CC_C; |
820 |
af = eflags & CC_A; |
821 |
al = EAX & 0xff;
|
822 |
|
823 |
eflags = 0;
|
824 |
al1 = al; |
825 |
if (((al & 0x0f) > 9 ) || af) { |
826 |
eflags |= CC_A; |
827 |
if (al < 6 || cf) |
828 |
eflags |= CC_C; |
829 |
al = (al - 6) & 0xff; |
830 |
} |
831 |
if ((al1 > 0x99) || cf) { |
832 |
al = (al - 0x60) & 0xff; |
833 |
eflags |= CC_C; |
834 |
} |
835 |
EAX = (EAX & ~0xff) | al;
|
836 |
/* well, speed is not an issue here, so we compute the flags by hand */
|
837 |
eflags |= (al == 0) << 6; /* zf */ |
838 |
eflags |= parity_table[al]; /* pf */
|
839 |
eflags |= (al & 0x80); /* sf */ |
840 |
CC_SRC = eflags; |
841 |
} |
842 |
|
843 |
/* segment handling */
|
844 |
|
845 |
/* never use it with R_CS */
|
846 |
void OPPROTO op_movl_seg_T0(void) |
847 |
{ |
848 |
load_seg(PARAM1, T0); |
849 |
} |
850 |
|
851 |
/* faster VM86 version */
|
852 |
void OPPROTO op_movl_seg_T0_vm(void) |
853 |
{ |
854 |
int selector;
|
855 |
SegmentCache *sc; |
856 |
|
857 |
selector = T0 & 0xffff;
|
858 |
/* env->segs[] access */
|
859 |
sc = (SegmentCache *)((char *)env + PARAM1);
|
860 |
sc->selector = selector; |
861 |
sc->base = (void *)(selector << 4); |
862 |
} |
863 |
|
864 |
void OPPROTO op_movl_T0_seg(void) |
865 |
{ |
866 |
T0 = env->segs[PARAM1].selector; |
867 |
} |
868 |
|
869 |
void OPPROTO op_movl_A0_seg(void) |
870 |
{ |
871 |
A0 = *(unsigned long *)((char *)env + PARAM1); |
872 |
} |
873 |
|
874 |
void OPPROTO op_addl_A0_seg(void) |
875 |
{ |
876 |
A0 += *(unsigned long *)((char *)env + PARAM1); |
877 |
} |
878 |
|
879 |
void OPPROTO op_lsl(void) |
880 |
{ |
881 |
helper_lsl(); |
882 |
} |
883 |
|
884 |
void OPPROTO op_lar(void) |
885 |
{ |
886 |
helper_lar(); |
887 |
} |
888 |
|
889 |
void OPPROTO op_verr(void) |
890 |
{ |
891 |
helper_verr(); |
892 |
} |
893 |
|
894 |
void OPPROTO op_verw(void) |
895 |
{ |
896 |
helper_verw(); |
897 |
} |
898 |
|
899 |
void OPPROTO op_arpl(void) |
900 |
{ |
901 |
if ((T0 & 3) < (T1 & 3)) { |
902 |
/* XXX: emulate bug or 0xff3f0000 oring as in bochs ? */
|
903 |
T0 = (T0 & ~3) | (T1 & 3); |
904 |
T1 = CC_Z; |
905 |
} else {
|
906 |
T1 = 0;
|
907 |
} |
908 |
FORCE_RET(); |
909 |
} |
910 |
|
911 |
void OPPROTO op_arpl_update(void) |
912 |
{ |
913 |
int eflags;
|
914 |
eflags = cc_table[CC_OP].compute_all(); |
915 |
CC_SRC = (eflags & ~CC_Z) | T1; |
916 |
} |
917 |
|
918 |
/* T0: segment, T1:eip */
|
919 |
void OPPROTO op_ljmp_protected_T0_T1(void) |
920 |
{ |
921 |
helper_ljmp_protected_T0_T1(); |
922 |
} |
923 |
|
924 |
void OPPROTO op_lcall_real_T0_T1(void) |
925 |
{ |
926 |
helper_lcall_real_T0_T1(PARAM1, PARAM2); |
927 |
} |
928 |
|
929 |
void OPPROTO op_lcall_protected_T0_T1(void) |
930 |
{ |
931 |
helper_lcall_protected_T0_T1(PARAM1, PARAM2); |
932 |
} |
933 |
|
934 |
void OPPROTO op_iret_real(void) |
935 |
{ |
936 |
helper_iret_real(PARAM1); |
937 |
} |
938 |
|
939 |
void OPPROTO op_iret_protected(void) |
940 |
{ |
941 |
helper_iret_protected(PARAM1); |
942 |
} |
943 |
|
944 |
void OPPROTO op_lret_protected(void) |
945 |
{ |
946 |
helper_lret_protected(PARAM1, PARAM2); |
947 |
} |
948 |
|
949 |
void OPPROTO op_lldt_T0(void) |
950 |
{ |
951 |
helper_lldt_T0(); |
952 |
} |
953 |
|
954 |
void OPPROTO op_ltr_T0(void) |
955 |
{ |
956 |
helper_ltr_T0(); |
957 |
} |
958 |
|
959 |
/* CR registers access */
|
960 |
void OPPROTO op_movl_crN_T0(void) |
961 |
{ |
962 |
helper_movl_crN_T0(PARAM1); |
963 |
} |
964 |
|
965 |
/* DR registers access */
|
966 |
void OPPROTO op_movl_drN_T0(void) |
967 |
{ |
968 |
helper_movl_drN_T0(PARAM1); |
969 |
} |
970 |
|
971 |
void OPPROTO op_lmsw_T0(void) |
972 |
{ |
973 |
/* only 4 lower bits of CR0 are modified */
|
974 |
T0 = (env->cr[0] & ~0xf) | (T0 & 0xf); |
975 |
helper_movl_crN_T0(0);
|
976 |
} |
977 |
|
978 |
void OPPROTO op_invlpg_A0(void) |
979 |
{ |
980 |
helper_invlpg(A0); |
981 |
} |
982 |
|
983 |
void OPPROTO op_movl_T0_env(void) |
984 |
{ |
985 |
T0 = *(uint32_t *)((char *)env + PARAM1);
|
986 |
} |
987 |
|
988 |
void OPPROTO op_movl_env_T0(void) |
989 |
{ |
990 |
*(uint32_t *)((char *)env + PARAM1) = T0;
|
991 |
} |
992 |
|
993 |
void OPPROTO op_movl_env_T1(void) |
994 |
{ |
995 |
*(uint32_t *)((char *)env + PARAM1) = T1;
|
996 |
} |
997 |
|
998 |
void OPPROTO op_clts(void) |
999 |
{ |
1000 |
env->cr[0] &= ~CR0_TS_MASK;
|
1001 |
} |
1002 |
|
1003 |
/* flags handling */
|
1004 |
|
1005 |
/* slow jumps cases : in order to avoid calling a function with a
|
1006 |
pointer (which can generate a stack frame on PowerPC), we use
|
1007 |
op_setcc to set T0 and then call op_jcc. */
|
1008 |
void OPPROTO op_jcc(void) |
1009 |
{ |
1010 |
if (T0)
|
1011 |
JUMP_TB(op_jcc, PARAM1, 0, PARAM2);
|
1012 |
else
|
1013 |
JUMP_TB(op_jcc, PARAM1, 1, PARAM3);
|
1014 |
FORCE_RET(); |
1015 |
} |
1016 |
|
1017 |
void OPPROTO op_jcc_im(void) |
1018 |
{ |
1019 |
if (T0)
|
1020 |
EIP = PARAM1; |
1021 |
else
|
1022 |
EIP = PARAM2; |
1023 |
FORCE_RET(); |
1024 |
} |
1025 |
|
1026 |
/* slow set cases (compute x86 flags) */
|
1027 |
void OPPROTO op_seto_T0_cc(void) |
1028 |
{ |
1029 |
int eflags;
|
1030 |
eflags = cc_table[CC_OP].compute_all(); |
1031 |
T0 = (eflags >> 11) & 1; |
1032 |
} |
1033 |
|
1034 |
void OPPROTO op_setb_T0_cc(void) |
1035 |
{ |
1036 |
T0 = cc_table[CC_OP].compute_c(); |
1037 |
} |
1038 |
|
1039 |
void OPPROTO op_setz_T0_cc(void) |
1040 |
{ |
1041 |
int eflags;
|
1042 |
eflags = cc_table[CC_OP].compute_all(); |
1043 |
T0 = (eflags >> 6) & 1; |
1044 |
} |
1045 |
|
1046 |
void OPPROTO op_setbe_T0_cc(void) |
1047 |
{ |
1048 |
int eflags;
|
1049 |
eflags = cc_table[CC_OP].compute_all(); |
1050 |
T0 = (eflags & (CC_Z | CC_C)) != 0;
|
1051 |
} |
1052 |
|
1053 |
void OPPROTO op_sets_T0_cc(void) |
1054 |
{ |
1055 |
int eflags;
|
1056 |
eflags = cc_table[CC_OP].compute_all(); |
1057 |
T0 = (eflags >> 7) & 1; |
1058 |
} |
1059 |
|
1060 |
void OPPROTO op_setp_T0_cc(void) |
1061 |
{ |
1062 |
int eflags;
|
1063 |
eflags = cc_table[CC_OP].compute_all(); |
1064 |
T0 = (eflags >> 2) & 1; |
1065 |
} |
1066 |
|
1067 |
void OPPROTO op_setl_T0_cc(void) |
1068 |
{ |
1069 |
int eflags;
|
1070 |
eflags = cc_table[CC_OP].compute_all(); |
1071 |
T0 = ((eflags ^ (eflags >> 4)) >> 7) & 1; |
1072 |
} |
1073 |
|
1074 |
void OPPROTO op_setle_T0_cc(void) |
1075 |
{ |
1076 |
int eflags;
|
1077 |
eflags = cc_table[CC_OP].compute_all(); |
1078 |
T0 = (((eflags ^ (eflags >> 4)) & 0x80) || (eflags & CC_Z)) != 0; |
1079 |
} |
1080 |
|
1081 |
void OPPROTO op_xor_T0_1(void) |
1082 |
{ |
1083 |
T0 ^= 1;
|
1084 |
} |
1085 |
|
1086 |
void OPPROTO op_set_cc_op(void) |
1087 |
{ |
1088 |
CC_OP = PARAM1; |
1089 |
} |
1090 |
|
1091 |
/* XXX: clear VIF/VIP in all ops ? */
|
1092 |
|
1093 |
void OPPROTO op_movl_eflags_T0(void) |
1094 |
{ |
1095 |
load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK)); |
1096 |
} |
1097 |
|
1098 |
void OPPROTO op_movw_eflags_T0(void) |
1099 |
{ |
1100 |
load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK) & 0xffff);
|
1101 |
} |
1102 |
|
1103 |
void OPPROTO op_movl_eflags_T0_io(void) |
1104 |
{ |
1105 |
load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK)); |
1106 |
} |
1107 |
|
1108 |
void OPPROTO op_movw_eflags_T0_io(void) |
1109 |
{ |
1110 |
load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK) & 0xffff);
|
1111 |
} |
1112 |
|
1113 |
void OPPROTO op_movl_eflags_T0_cpl0(void) |
1114 |
{ |
1115 |
load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK)); |
1116 |
} |
1117 |
|
1118 |
void OPPROTO op_movw_eflags_T0_cpl0(void) |
1119 |
{ |
1120 |
load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK) & 0xffff);
|
1121 |
} |
1122 |
|
1123 |
#if 0
|
1124 |
/* vm86plus version */
|
1125 |
void OPPROTO op_movw_eflags_T0_vm(void)
|
1126 |
{
|
1127 |
int eflags;
|
1128 |
eflags = T0;
|
1129 |
CC_SRC = eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
|
1130 |
DF = 1 - (2 * ((eflags >> 10) & 1));
|
1131 |
/* we also update some system flags as in user mode */
|
1132 |
env->eflags = (env->eflags & ~(FL_UPDATE_MASK16 | VIF_MASK)) |
|
1133 |
(eflags & FL_UPDATE_MASK16);
|
1134 |
if (eflags & IF_MASK) {
|
1135 |
env->eflags |= VIF_MASK;
|
1136 |
if (env->eflags & VIP_MASK) {
|
1137 |
EIP = PARAM1;
|
1138 |
raise_exception(EXCP0D_GPF);
|
1139 |
}
|
1140 |
}
|
1141 |
FORCE_RET();
|
1142 |
}
|
1143 |
|
1144 |
void OPPROTO op_movl_eflags_T0_vm(void)
|
1145 |
{
|
1146 |
int eflags;
|
1147 |
eflags = T0;
|
1148 |
CC_SRC = eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
|
1149 |
DF = 1 - (2 * ((eflags >> 10) & 1));
|
1150 |
/* we also update some system flags as in user mode */
|
1151 |
env->eflags = (env->eflags & ~(FL_UPDATE_MASK32 | VIF_MASK)) |
|
1152 |
(eflags & FL_UPDATE_MASK32);
|
1153 |
if (eflags & IF_MASK) {
|
1154 |
env->eflags |= VIF_MASK;
|
1155 |
if (env->eflags & VIP_MASK) {
|
1156 |
EIP = PARAM1;
|
1157 |
raise_exception(EXCP0D_GPF);
|
1158 |
}
|
1159 |
}
|
1160 |
FORCE_RET();
|
1161 |
}
|
1162 |
#endif
|
1163 |
|
1164 |
/* XXX: compute only O flag */
|
1165 |
void OPPROTO op_movb_eflags_T0(void) |
1166 |
{ |
1167 |
int of;
|
1168 |
of = cc_table[CC_OP].compute_all() & CC_O; |
1169 |
CC_SRC = (T0 & (CC_S | CC_Z | CC_A | CC_P | CC_C)) | of; |
1170 |
} |
1171 |
|
1172 |
void OPPROTO op_movl_T0_eflags(void) |
1173 |
{ |
1174 |
int eflags;
|
1175 |
eflags = cc_table[CC_OP].compute_all(); |
1176 |
eflags |= (DF & DF_MASK); |
1177 |
eflags |= env->eflags & ~(VM_MASK | RF_MASK); |
1178 |
T0 = eflags; |
1179 |
} |
1180 |
|
1181 |
/* vm86plus version */
|
1182 |
#if 0
|
1183 |
void OPPROTO op_movl_T0_eflags_vm(void)
|
1184 |
{
|
1185 |
int eflags;
|
1186 |
eflags = cc_table[CC_OP].compute_all();
|
1187 |
eflags |= (DF & DF_MASK);
|
1188 |
eflags |= env->eflags & ~(VM_MASK | RF_MASK | IF_MASK);
|
1189 |
if (env->eflags & VIF_MASK)
|
1190 |
eflags |= IF_MASK;
|
1191 |
T0 = eflags;
|
1192 |
}
|
1193 |
#endif
|
1194 |
|
1195 |
void OPPROTO op_cld(void) |
1196 |
{ |
1197 |
DF = 1;
|
1198 |
} |
1199 |
|
1200 |
void OPPROTO op_std(void) |
1201 |
{ |
1202 |
DF = -1;
|
1203 |
} |
1204 |
|
1205 |
void OPPROTO op_clc(void) |
1206 |
{ |
1207 |
int eflags;
|
1208 |
eflags = cc_table[CC_OP].compute_all(); |
1209 |
eflags &= ~CC_C; |
1210 |
CC_SRC = eflags; |
1211 |
} |
1212 |
|
1213 |
void OPPROTO op_stc(void) |
1214 |
{ |
1215 |
int eflags;
|
1216 |
eflags = cc_table[CC_OP].compute_all(); |
1217 |
eflags |= CC_C; |
1218 |
CC_SRC = eflags; |
1219 |
} |
1220 |
|
1221 |
void OPPROTO op_cmc(void) |
1222 |
{ |
1223 |
int eflags;
|
1224 |
eflags = cc_table[CC_OP].compute_all(); |
1225 |
eflags ^= CC_C; |
1226 |
CC_SRC = eflags; |
1227 |
} |
1228 |
|
1229 |
void OPPROTO op_salc(void) |
1230 |
{ |
1231 |
int cf;
|
1232 |
cf = cc_table[CC_OP].compute_c(); |
1233 |
EAX = (EAX & ~0xff) | ((-cf) & 0xff); |
1234 |
} |
1235 |
|
1236 |
static int compute_all_eflags(void) |
1237 |
{ |
1238 |
return CC_SRC;
|
1239 |
} |
1240 |
|
1241 |
static int compute_c_eflags(void) |
1242 |
{ |
1243 |
return CC_SRC & CC_C;
|
1244 |
} |
1245 |
|
1246 |
CCTable cc_table[CC_OP_NB] = { |
1247 |
[CC_OP_DYNAMIC] = { /* should never happen */ },
|
1248 |
|
1249 |
[CC_OP_EFLAGS] = { compute_all_eflags, compute_c_eflags }, |
1250 |
|
1251 |
[CC_OP_MULB] = { compute_all_mulb, compute_c_mull }, |
1252 |
[CC_OP_MULW] = { compute_all_mulw, compute_c_mull }, |
1253 |
[CC_OP_MULL] = { compute_all_mull, compute_c_mull }, |
1254 |
|
1255 |
[CC_OP_ADDB] = { compute_all_addb, compute_c_addb }, |
1256 |
[CC_OP_ADDW] = { compute_all_addw, compute_c_addw }, |
1257 |
[CC_OP_ADDL] = { compute_all_addl, compute_c_addl }, |
1258 |
|
1259 |
[CC_OP_ADCB] = { compute_all_adcb, compute_c_adcb }, |
1260 |
[CC_OP_ADCW] = { compute_all_adcw, compute_c_adcw }, |
1261 |
[CC_OP_ADCL] = { compute_all_adcl, compute_c_adcl }, |
1262 |
|
1263 |
[CC_OP_SUBB] = { compute_all_subb, compute_c_subb }, |
1264 |
[CC_OP_SUBW] = { compute_all_subw, compute_c_subw }, |
1265 |
[CC_OP_SUBL] = { compute_all_subl, compute_c_subl }, |
1266 |
|
1267 |
[CC_OP_SBBB] = { compute_all_sbbb, compute_c_sbbb }, |
1268 |
[CC_OP_SBBW] = { compute_all_sbbw, compute_c_sbbw }, |
1269 |
[CC_OP_SBBL] = { compute_all_sbbl, compute_c_sbbl }, |
1270 |
|
1271 |
[CC_OP_LOGICB] = { compute_all_logicb, compute_c_logicb }, |
1272 |
[CC_OP_LOGICW] = { compute_all_logicw, compute_c_logicw }, |
1273 |
[CC_OP_LOGICL] = { compute_all_logicl, compute_c_logicl }, |
1274 |
|
1275 |
[CC_OP_INCB] = { compute_all_incb, compute_c_incl }, |
1276 |
[CC_OP_INCW] = { compute_all_incw, compute_c_incl }, |
1277 |
[CC_OP_INCL] = { compute_all_incl, compute_c_incl }, |
1278 |
|
1279 |
[CC_OP_DECB] = { compute_all_decb, compute_c_incl }, |
1280 |
[CC_OP_DECW] = { compute_all_decw, compute_c_incl }, |
1281 |
[CC_OP_DECL] = { compute_all_decl, compute_c_incl }, |
1282 |
|
1283 |
[CC_OP_SHLB] = { compute_all_shlb, compute_c_shlb }, |
1284 |
[CC_OP_SHLW] = { compute_all_shlw, compute_c_shlw }, |
1285 |
[CC_OP_SHLL] = { compute_all_shll, compute_c_shll }, |
1286 |
|
1287 |
[CC_OP_SARB] = { compute_all_sarb, compute_c_sarl }, |
1288 |
[CC_OP_SARW] = { compute_all_sarw, compute_c_sarl }, |
1289 |
[CC_OP_SARL] = { compute_all_sarl, compute_c_sarl }, |
1290 |
}; |
1291 |
|
1292 |
/* floating point support. Some of the code for complicated x87
|
1293 |
functions comes from the LGPL'ed x86 emulator found in the Willows
|
1294 |
TWIN windows emulator. */
|
1295 |
|
1296 |
#if defined(__powerpc__)
|
1297 |
extern CPU86_LDouble copysign(CPU86_LDouble, CPU86_LDouble);
|
1298 |
|
1299 |
/* correct (but slow) PowerPC rint() (glibc version is incorrect) */
|
1300 |
double qemu_rint(double x) |
1301 |
{ |
1302 |
double y = 4503599627370496.0; |
1303 |
if (fabs(x) >= y)
|
1304 |
return x;
|
1305 |
if (x < 0) |
1306 |
y = -y; |
1307 |
y = (x + y) - y; |
1308 |
if (y == 0.0) |
1309 |
y = copysign(y, x); |
1310 |
return y;
|
1311 |
} |
1312 |
|
1313 |
#define rint qemu_rint
|
1314 |
#endif
|
1315 |
|
1316 |
/* fp load FT0 */
|
1317 |
|
1318 |
void OPPROTO op_flds_FT0_A0(void) |
1319 |
{ |
1320 |
#ifdef USE_FP_CONVERT
|
1321 |
FP_CONVERT.i32 = ldl((void *)A0);
|
1322 |
FT0 = FP_CONVERT.f; |
1323 |
#else
|
1324 |
FT0 = ldfl((void *)A0);
|
1325 |
#endif
|
1326 |
} |
1327 |
|
1328 |
void OPPROTO op_fldl_FT0_A0(void) |
1329 |
{ |
1330 |
#ifdef USE_FP_CONVERT
|
1331 |
FP_CONVERT.i64 = ldq((void *)A0);
|
1332 |
FT0 = FP_CONVERT.d; |
1333 |
#else
|
1334 |
FT0 = ldfq((void *)A0);
|
1335 |
#endif
|
1336 |
} |
1337 |
|
1338 |
/* helpers are needed to avoid static constant reference. XXX: find a better way */
|
1339 |
#ifdef USE_INT_TO_FLOAT_HELPERS
|
1340 |
|
1341 |
void helper_fild_FT0_A0(void) |
1342 |
{ |
1343 |
FT0 = (CPU86_LDouble)ldsw((void *)A0);
|
1344 |
} |
1345 |
|
1346 |
void helper_fildl_FT0_A0(void) |
1347 |
{ |
1348 |
FT0 = (CPU86_LDouble)((int32_t)ldl((void *)A0));
|
1349 |
} |
1350 |
|
1351 |
void helper_fildll_FT0_A0(void) |
1352 |
{ |
1353 |
FT0 = (CPU86_LDouble)((int64_t)ldq((void *)A0));
|
1354 |
} |
1355 |
|
1356 |
void OPPROTO op_fild_FT0_A0(void) |
1357 |
{ |
1358 |
helper_fild_FT0_A0(); |
1359 |
} |
1360 |
|
1361 |
void OPPROTO op_fildl_FT0_A0(void) |
1362 |
{ |
1363 |
helper_fildl_FT0_A0(); |
1364 |
} |
1365 |
|
1366 |
void OPPROTO op_fildll_FT0_A0(void) |
1367 |
{ |
1368 |
helper_fildll_FT0_A0(); |
1369 |
} |
1370 |
|
1371 |
#else
|
1372 |
|
1373 |
void OPPROTO op_fild_FT0_A0(void) |
1374 |
{ |
1375 |
#ifdef USE_FP_CONVERT
|
1376 |
FP_CONVERT.i32 = ldsw((void *)A0);
|
1377 |
FT0 = (CPU86_LDouble)FP_CONVERT.i32; |
1378 |
#else
|
1379 |
FT0 = (CPU86_LDouble)ldsw((void *)A0);
|
1380 |
#endif
|
1381 |
} |
1382 |
|
1383 |
void OPPROTO op_fildl_FT0_A0(void) |
1384 |
{ |
1385 |
#ifdef USE_FP_CONVERT
|
1386 |
FP_CONVERT.i32 = (int32_t) ldl((void *)A0);
|
1387 |
FT0 = (CPU86_LDouble)FP_CONVERT.i32; |
1388 |
#else
|
1389 |
FT0 = (CPU86_LDouble)((int32_t)ldl((void *)A0));
|
1390 |
#endif
|
1391 |
} |
1392 |
|
1393 |
void OPPROTO op_fildll_FT0_A0(void) |
1394 |
{ |
1395 |
#ifdef USE_FP_CONVERT
|
1396 |
FP_CONVERT.i64 = (int64_t) ldq((void *)A0);
|
1397 |
FT0 = (CPU86_LDouble)FP_CONVERT.i64; |
1398 |
#else
|
1399 |
FT0 = (CPU86_LDouble)((int64_t)ldq((void *)A0));
|
1400 |
#endif
|
1401 |
} |
1402 |
#endif
|
1403 |
|
1404 |
/* fp load ST0 */
|
1405 |
|
1406 |
void OPPROTO op_flds_ST0_A0(void) |
1407 |
{ |
1408 |
int new_fpstt;
|
1409 |
new_fpstt = (env->fpstt - 1) & 7; |
1410 |
#ifdef USE_FP_CONVERT
|
1411 |
FP_CONVERT.i32 = ldl((void *)A0);
|
1412 |
env->fpregs[new_fpstt] = FP_CONVERT.f; |
1413 |
#else
|
1414 |
env->fpregs[new_fpstt] = ldfl((void *)A0);
|
1415 |
#endif
|
1416 |
env->fpstt = new_fpstt; |
1417 |
env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1418 |
} |
1419 |
|
1420 |
void OPPROTO op_fldl_ST0_A0(void) |
1421 |
{ |
1422 |
int new_fpstt;
|
1423 |
new_fpstt = (env->fpstt - 1) & 7; |
1424 |
#ifdef USE_FP_CONVERT
|
1425 |
FP_CONVERT.i64 = ldq((void *)A0);
|
1426 |
env->fpregs[new_fpstt] = FP_CONVERT.d; |
1427 |
#else
|
1428 |
env->fpregs[new_fpstt] = ldfq((void *)A0);
|
1429 |
#endif
|
1430 |
env->fpstt = new_fpstt; |
1431 |
env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1432 |
} |
1433 |
|
1434 |
void OPPROTO op_fldt_ST0_A0(void) |
1435 |
{ |
1436 |
helper_fldt_ST0_A0(); |
1437 |
} |
1438 |
|
1439 |
/* helpers are needed to avoid static constant reference. XXX: find a better way */
|
1440 |
#ifdef USE_INT_TO_FLOAT_HELPERS
|
1441 |
|
1442 |
void helper_fild_ST0_A0(void) |
1443 |
{ |
1444 |
int new_fpstt;
|
1445 |
new_fpstt = (env->fpstt - 1) & 7; |
1446 |
env->fpregs[new_fpstt] = (CPU86_LDouble)ldsw((void *)A0);
|
1447 |
env->fpstt = new_fpstt; |
1448 |
env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1449 |
} |
1450 |
|
1451 |
void helper_fildl_ST0_A0(void) |
1452 |
{ |
1453 |
int new_fpstt;
|
1454 |
new_fpstt = (env->fpstt - 1) & 7; |
1455 |
env->fpregs[new_fpstt] = (CPU86_LDouble)((int32_t)ldl((void *)A0));
|
1456 |
env->fpstt = new_fpstt; |
1457 |
env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1458 |
} |
1459 |
|
1460 |
void helper_fildll_ST0_A0(void) |
1461 |
{ |
1462 |
int new_fpstt;
|
1463 |
new_fpstt = (env->fpstt - 1) & 7; |
1464 |
env->fpregs[new_fpstt] = (CPU86_LDouble)((int64_t)ldq((void *)A0));
|
1465 |
env->fpstt = new_fpstt; |
1466 |
env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1467 |
} |
1468 |
|
1469 |
void OPPROTO op_fild_ST0_A0(void) |
1470 |
{ |
1471 |
helper_fild_ST0_A0(); |
1472 |
} |
1473 |
|
1474 |
void OPPROTO op_fildl_ST0_A0(void) |
1475 |
{ |
1476 |
helper_fildl_ST0_A0(); |
1477 |
} |
1478 |
|
1479 |
void OPPROTO op_fildll_ST0_A0(void) |
1480 |
{ |
1481 |
helper_fildll_ST0_A0(); |
1482 |
} |
1483 |
|
1484 |
#else
|
1485 |
|
1486 |
void OPPROTO op_fild_ST0_A0(void) |
1487 |
{ |
1488 |
int new_fpstt;
|
1489 |
new_fpstt = (env->fpstt - 1) & 7; |
1490 |
#ifdef USE_FP_CONVERT
|
1491 |
FP_CONVERT.i32 = ldsw((void *)A0);
|
1492 |
env->fpregs[new_fpstt] = (CPU86_LDouble)FP_CONVERT.i32; |
1493 |
#else
|
1494 |
env->fpregs[new_fpstt] = (CPU86_LDouble)ldsw((void *)A0);
|
1495 |
#endif
|
1496 |
env->fpstt = new_fpstt; |
1497 |
env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1498 |
} |
1499 |
|
1500 |
void OPPROTO op_fildl_ST0_A0(void) |
1501 |
{ |
1502 |
int new_fpstt;
|
1503 |
new_fpstt = (env->fpstt - 1) & 7; |
1504 |
#ifdef USE_FP_CONVERT
|
1505 |
FP_CONVERT.i32 = (int32_t) ldl((void *)A0);
|
1506 |
env->fpregs[new_fpstt] = (CPU86_LDouble)FP_CONVERT.i32; |
1507 |
#else
|
1508 |
env->fpregs[new_fpstt] = (CPU86_LDouble)((int32_t)ldl((void *)A0));
|
1509 |
#endif
|
1510 |
env->fpstt = new_fpstt; |
1511 |
env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1512 |
} |
1513 |
|
1514 |
void OPPROTO op_fildll_ST0_A0(void) |
1515 |
{ |
1516 |
int new_fpstt;
|
1517 |
new_fpstt = (env->fpstt - 1) & 7; |
1518 |
#ifdef USE_FP_CONVERT
|
1519 |
FP_CONVERT.i64 = (int64_t) ldq((void *)A0);
|
1520 |
env->fpregs[new_fpstt] = (CPU86_LDouble)FP_CONVERT.i64; |
1521 |
#else
|
1522 |
env->fpregs[new_fpstt] = (CPU86_LDouble)((int64_t)ldq((void *)A0));
|
1523 |
#endif
|
1524 |
env->fpstt = new_fpstt; |
1525 |
env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1526 |
} |
1527 |
|
1528 |
#endif
|
1529 |
|
1530 |
/* fp store */
|
1531 |
|
1532 |
void OPPROTO op_fsts_ST0_A0(void) |
1533 |
{ |
1534 |
#ifdef USE_FP_CONVERT
|
1535 |
FP_CONVERT.f = (float)ST0;
|
1536 |
stfl((void *)A0, FP_CONVERT.f);
|
1537 |
#else
|
1538 |
stfl((void *)A0, (float)ST0); |
1539 |
#endif
|
1540 |
} |
1541 |
|
1542 |
void OPPROTO op_fstl_ST0_A0(void) |
1543 |
{ |
1544 |
stfq((void *)A0, (double)ST0); |
1545 |
} |
1546 |
|
1547 |
void OPPROTO op_fstt_ST0_A0(void) |
1548 |
{ |
1549 |
helper_fstt_ST0_A0(); |
1550 |
} |
1551 |
|
1552 |
void OPPROTO op_fist_ST0_A0(void) |
1553 |
{ |
1554 |
#if defined(__sparc__) && !defined(__sparc_v9__)
|
1555 |
register CPU86_LDouble d asm("o0"); |
1556 |
#else
|
1557 |
CPU86_LDouble d; |
1558 |
#endif
|
1559 |
int val;
|
1560 |
|
1561 |
d = ST0; |
1562 |
val = lrint(d); |
1563 |
if (val != (int16_t)val)
|
1564 |
val = -32768;
|
1565 |
stw((void *)A0, val);
|
1566 |
} |
1567 |
|
1568 |
void OPPROTO op_fistl_ST0_A0(void) |
1569 |
{ |
1570 |
#if defined(__sparc__) && !defined(__sparc_v9__)
|
1571 |
register CPU86_LDouble d asm("o0"); |
1572 |
#else
|
1573 |
CPU86_LDouble d; |
1574 |
#endif
|
1575 |
int val;
|
1576 |
|
1577 |
d = ST0; |
1578 |
val = lrint(d); |
1579 |
stl((void *)A0, val);
|
1580 |
} |
1581 |
|
1582 |
void OPPROTO op_fistll_ST0_A0(void) |
1583 |
{ |
1584 |
#if defined(__sparc__) && !defined(__sparc_v9__)
|
1585 |
register CPU86_LDouble d asm("o0"); |
1586 |
#else
|
1587 |
CPU86_LDouble d; |
1588 |
#endif
|
1589 |
int64_t val; |
1590 |
|
1591 |
d = ST0; |
1592 |
val = llrint(d); |
1593 |
stq((void *)A0, val);
|
1594 |
} |
1595 |
|
1596 |
void OPPROTO op_fbld_ST0_A0(void) |
1597 |
{ |
1598 |
helper_fbld_ST0_A0(); |
1599 |
} |
1600 |
|
1601 |
void OPPROTO op_fbst_ST0_A0(void) |
1602 |
{ |
1603 |
helper_fbst_ST0_A0(); |
1604 |
} |
1605 |
|
1606 |
/* FPU move */
|
1607 |
|
1608 |
void OPPROTO op_fpush(void) |
1609 |
{ |
1610 |
fpush(); |
1611 |
} |
1612 |
|
1613 |
void OPPROTO op_fpop(void) |
1614 |
{ |
1615 |
fpop(); |
1616 |
} |
1617 |
|
1618 |
void OPPROTO op_fdecstp(void) |
1619 |
{ |
1620 |
env->fpstt = (env->fpstt - 1) & 7; |
1621 |
env->fpus &= (~0x4700);
|
1622 |
} |
1623 |
|
1624 |
void OPPROTO op_fincstp(void) |
1625 |
{ |
1626 |
env->fpstt = (env->fpstt + 1) & 7; |
1627 |
env->fpus &= (~0x4700);
|
1628 |
} |
1629 |
|
1630 |
void OPPROTO op_fmov_ST0_FT0(void) |
1631 |
{ |
1632 |
ST0 = FT0; |
1633 |
} |
1634 |
|
1635 |
void OPPROTO op_fmov_FT0_STN(void) |
1636 |
{ |
1637 |
FT0 = ST(PARAM1); |
1638 |
} |
1639 |
|
1640 |
void OPPROTO op_fmov_ST0_STN(void) |
1641 |
{ |
1642 |
ST0 = ST(PARAM1); |
1643 |
} |
1644 |
|
1645 |
void OPPROTO op_fmov_STN_ST0(void) |
1646 |
{ |
1647 |
ST(PARAM1) = ST0; |
1648 |
} |
1649 |
|
1650 |
void OPPROTO op_fxchg_ST0_STN(void) |
1651 |
{ |
1652 |
CPU86_LDouble tmp; |
1653 |
tmp = ST(PARAM1); |
1654 |
ST(PARAM1) = ST0; |
1655 |
ST0 = tmp; |
1656 |
} |
1657 |
|
1658 |
/* FPU operations */
|
1659 |
|
1660 |
/* XXX: handle nans */
|
1661 |
void OPPROTO op_fcom_ST0_FT0(void) |
1662 |
{ |
1663 |
env->fpus &= (~0x4500); /* (C3,C2,C0) <-- 000 */ |
1664 |
if (ST0 < FT0)
|
1665 |
env->fpus |= 0x100; /* (C3,C2,C0) <-- 001 */ |
1666 |
else if (ST0 == FT0) |
1667 |
env->fpus |= 0x4000; /* (C3,C2,C0) <-- 100 */ |
1668 |
FORCE_RET(); |
1669 |
} |
1670 |
|
1671 |
/* XXX: handle nans */
|
1672 |
void OPPROTO op_fucom_ST0_FT0(void) |
1673 |
{ |
1674 |
env->fpus &= (~0x4500); /* (C3,C2,C0) <-- 000 */ |
1675 |
if (ST0 < FT0)
|
1676 |
env->fpus |= 0x100; /* (C3,C2,C0) <-- 001 */ |
1677 |
else if (ST0 == FT0) |
1678 |
env->fpus |= 0x4000; /* (C3,C2,C0) <-- 100 */ |
1679 |
FORCE_RET(); |
1680 |
} |
1681 |
|
1682 |
/* XXX: handle nans */
|
1683 |
void OPPROTO op_fcomi_ST0_FT0(void) |
1684 |
{ |
1685 |
int eflags;
|
1686 |
eflags = cc_table[CC_OP].compute_all(); |
1687 |
eflags &= ~(CC_Z | CC_P | CC_C); |
1688 |
if (ST0 < FT0)
|
1689 |
eflags |= CC_C; |
1690 |
else if (ST0 == FT0) |
1691 |
eflags |= CC_Z; |
1692 |
CC_SRC = eflags; |
1693 |
FORCE_RET(); |
1694 |
} |
1695 |
|
1696 |
/* XXX: handle nans */
|
1697 |
void OPPROTO op_fucomi_ST0_FT0(void) |
1698 |
{ |
1699 |
int eflags;
|
1700 |
eflags = cc_table[CC_OP].compute_all(); |
1701 |
eflags &= ~(CC_Z | CC_P | CC_C); |
1702 |
if (ST0 < FT0)
|
1703 |
eflags |= CC_C; |
1704 |
else if (ST0 == FT0) |
1705 |
eflags |= CC_Z; |
1706 |
CC_SRC = eflags; |
1707 |
FORCE_RET(); |
1708 |
} |
1709 |
|
1710 |
void OPPROTO op_fcmov_ST0_STN_T0(void) |
1711 |
{ |
1712 |
if (T0) {
|
1713 |
ST0 = ST(PARAM1); |
1714 |
} |
1715 |
FORCE_RET(); |
1716 |
} |
1717 |
|
1718 |
void OPPROTO op_fadd_ST0_FT0(void) |
1719 |
{ |
1720 |
ST0 += FT0; |
1721 |
} |
1722 |
|
1723 |
void OPPROTO op_fmul_ST0_FT0(void) |
1724 |
{ |
1725 |
ST0 *= FT0; |
1726 |
} |
1727 |
|
1728 |
void OPPROTO op_fsub_ST0_FT0(void) |
1729 |
{ |
1730 |
ST0 -= FT0; |
1731 |
} |
1732 |
|
1733 |
void OPPROTO op_fsubr_ST0_FT0(void) |
1734 |
{ |
1735 |
ST0 = FT0 - ST0; |
1736 |
} |
1737 |
|
1738 |
void OPPROTO op_fdiv_ST0_FT0(void) |
1739 |
{ |
1740 |
ST0 /= FT0; |
1741 |
} |
1742 |
|
1743 |
void OPPROTO op_fdivr_ST0_FT0(void) |
1744 |
{ |
1745 |
ST0 = FT0 / ST0; |
1746 |
} |
1747 |
|
1748 |
/* fp operations between STN and ST0 */
|
1749 |
|
1750 |
void OPPROTO op_fadd_STN_ST0(void) |
1751 |
{ |
1752 |
ST(PARAM1) += ST0; |
1753 |
} |
1754 |
|
1755 |
void OPPROTO op_fmul_STN_ST0(void) |
1756 |
{ |
1757 |
ST(PARAM1) *= ST0; |
1758 |
} |
1759 |
|
1760 |
void OPPROTO op_fsub_STN_ST0(void) |
1761 |
{ |
1762 |
ST(PARAM1) -= ST0; |
1763 |
} |
1764 |
|
1765 |
void OPPROTO op_fsubr_STN_ST0(void) |
1766 |
{ |
1767 |
CPU86_LDouble *p; |
1768 |
p = &ST(PARAM1); |
1769 |
*p = ST0 - *p; |
1770 |
} |
1771 |
|
1772 |
void OPPROTO op_fdiv_STN_ST0(void) |
1773 |
{ |
1774 |
ST(PARAM1) /= ST0; |
1775 |
} |
1776 |
|
1777 |
void OPPROTO op_fdivr_STN_ST0(void) |
1778 |
{ |
1779 |
CPU86_LDouble *p; |
1780 |
p = &ST(PARAM1); |
1781 |
*p = ST0 / *p; |
1782 |
} |
1783 |
|
1784 |
/* misc FPU operations */
|
1785 |
void OPPROTO op_fchs_ST0(void) |
1786 |
{ |
1787 |
ST0 = -ST0; |
1788 |
} |
1789 |
|
1790 |
void OPPROTO op_fabs_ST0(void) |
1791 |
{ |
1792 |
ST0 = fabs(ST0); |
1793 |
} |
1794 |
|
1795 |
void OPPROTO op_fxam_ST0(void) |
1796 |
{ |
1797 |
helper_fxam_ST0(); |
1798 |
} |
1799 |
|
1800 |
void OPPROTO op_fld1_ST0(void) |
1801 |
{ |
1802 |
ST0 = f15rk[1];
|
1803 |
} |
1804 |
|
1805 |
void OPPROTO op_fldl2t_ST0(void) |
1806 |
{ |
1807 |
ST0 = f15rk[6];
|
1808 |
} |
1809 |
|
1810 |
void OPPROTO op_fldl2e_ST0(void) |
1811 |
{ |
1812 |
ST0 = f15rk[5];
|
1813 |
} |
1814 |
|
1815 |
void OPPROTO op_fldpi_ST0(void) |
1816 |
{ |
1817 |
ST0 = f15rk[2];
|
1818 |
} |
1819 |
|
1820 |
void OPPROTO op_fldlg2_ST0(void) |
1821 |
{ |
1822 |
ST0 = f15rk[3];
|
1823 |
} |
1824 |
|
1825 |
void OPPROTO op_fldln2_ST0(void) |
1826 |
{ |
1827 |
ST0 = f15rk[4];
|
1828 |
} |
1829 |
|
1830 |
void OPPROTO op_fldz_ST0(void) |
1831 |
{ |
1832 |
ST0 = f15rk[0];
|
1833 |
} |
1834 |
|
1835 |
void OPPROTO op_fldz_FT0(void) |
1836 |
{ |
1837 |
FT0 = f15rk[0];
|
1838 |
} |
1839 |
|
1840 |
/* associated heplers to reduce generated code length and to simplify
|
1841 |
relocation (FP constants are usually stored in .rodata section) */
|
1842 |
|
1843 |
void OPPROTO op_f2xm1(void) |
1844 |
{ |
1845 |
helper_f2xm1(); |
1846 |
} |
1847 |
|
1848 |
void OPPROTO op_fyl2x(void) |
1849 |
{ |
1850 |
helper_fyl2x(); |
1851 |
} |
1852 |
|
1853 |
void OPPROTO op_fptan(void) |
1854 |
{ |
1855 |
helper_fptan(); |
1856 |
} |
1857 |
|
1858 |
void OPPROTO op_fpatan(void) |
1859 |
{ |
1860 |
helper_fpatan(); |
1861 |
} |
1862 |
|
1863 |
void OPPROTO op_fxtract(void) |
1864 |
{ |
1865 |
helper_fxtract(); |
1866 |
} |
1867 |
|
1868 |
void OPPROTO op_fprem1(void) |
1869 |
{ |
1870 |
helper_fprem1(); |
1871 |
} |
1872 |
|
1873 |
|
1874 |
void OPPROTO op_fprem(void) |
1875 |
{ |
1876 |
helper_fprem(); |
1877 |
} |
1878 |
|
1879 |
void OPPROTO op_fyl2xp1(void) |
1880 |
{ |
1881 |
helper_fyl2xp1(); |
1882 |
} |
1883 |
|
1884 |
void OPPROTO op_fsqrt(void) |
1885 |
{ |
1886 |
helper_fsqrt(); |
1887 |
} |
1888 |
|
1889 |
void OPPROTO op_fsincos(void) |
1890 |
{ |
1891 |
helper_fsincos(); |
1892 |
} |
1893 |
|
1894 |
void OPPROTO op_frndint(void) |
1895 |
{ |
1896 |
helper_frndint(); |
1897 |
} |
1898 |
|
1899 |
void OPPROTO op_fscale(void) |
1900 |
{ |
1901 |
helper_fscale(); |
1902 |
} |
1903 |
|
1904 |
void OPPROTO op_fsin(void) |
1905 |
{ |
1906 |
helper_fsin(); |
1907 |
} |
1908 |
|
1909 |
void OPPROTO op_fcos(void) |
1910 |
{ |
1911 |
helper_fcos(); |
1912 |
} |
1913 |
|
1914 |
void OPPROTO op_fnstsw_A0(void) |
1915 |
{ |
1916 |
int fpus;
|
1917 |
fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; |
1918 |
stw((void *)A0, fpus);
|
1919 |
} |
1920 |
|
1921 |
void OPPROTO op_fnstsw_EAX(void) |
1922 |
{ |
1923 |
int fpus;
|
1924 |
fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; |
1925 |
EAX = (EAX & 0xffff0000) | fpus;
|
1926 |
} |
1927 |
|
1928 |
void OPPROTO op_fnstcw_A0(void) |
1929 |
{ |
1930 |
stw((void *)A0, env->fpuc);
|
1931 |
} |
1932 |
|
1933 |
void OPPROTO op_fldcw_A0(void) |
1934 |
{ |
1935 |
int rnd_type;
|
1936 |
env->fpuc = lduw((void *)A0);
|
1937 |
/* set rounding mode */
|
1938 |
switch(env->fpuc & RC_MASK) {
|
1939 |
default:
|
1940 |
case RC_NEAR:
|
1941 |
rnd_type = FE_TONEAREST; |
1942 |
break;
|
1943 |
case RC_DOWN:
|
1944 |
rnd_type = FE_DOWNWARD; |
1945 |
break;
|
1946 |
case RC_UP:
|
1947 |
rnd_type = FE_UPWARD; |
1948 |
break;
|
1949 |
case RC_CHOP:
|
1950 |
rnd_type = FE_TOWARDZERO; |
1951 |
break;
|
1952 |
} |
1953 |
fesetround(rnd_type); |
1954 |
} |
1955 |
|
1956 |
void OPPROTO op_fclex(void) |
1957 |
{ |
1958 |
env->fpus &= 0x7f00;
|
1959 |
} |
1960 |
|
1961 |
void OPPROTO op_fninit(void) |
1962 |
{ |
1963 |
env->fpus = 0;
|
1964 |
env->fpstt = 0;
|
1965 |
env->fpuc = 0x37f;
|
1966 |
env->fptags[0] = 1; |
1967 |
env->fptags[1] = 1; |
1968 |
env->fptags[2] = 1; |
1969 |
env->fptags[3] = 1; |
1970 |
env->fptags[4] = 1; |
1971 |
env->fptags[5] = 1; |
1972 |
env->fptags[6] = 1; |
1973 |
env->fptags[7] = 1; |
1974 |
} |
1975 |
|
1976 |
void OPPROTO op_fnstenv_A0(void) |
1977 |
{ |
1978 |
helper_fstenv((uint8_t *)A0, PARAM1); |
1979 |
} |
1980 |
|
1981 |
void OPPROTO op_fldenv_A0(void) |
1982 |
{ |
1983 |
helper_fldenv((uint8_t *)A0, PARAM1); |
1984 |
} |
1985 |
|
1986 |
void OPPROTO op_fnsave_A0(void) |
1987 |
{ |
1988 |
helper_fsave((uint8_t *)A0, PARAM1); |
1989 |
} |
1990 |
|
1991 |
void OPPROTO op_frstor_A0(void) |
1992 |
{ |
1993 |
helper_frstor((uint8_t *)A0, PARAM1); |
1994 |
} |
1995 |
|
1996 |
/* threading support */
|
1997 |
void OPPROTO op_lock(void) |
1998 |
{ |
1999 |
cpu_lock(); |
2000 |
} |
2001 |
|
2002 |
void OPPROTO op_unlock(void) |
2003 |
{ |
2004 |
cpu_unlock(); |
2005 |
} |
2006 |
|