1 /*---------------------------------------------------------------------------+
4 | Implement a few FPU instructions. |
6 | Copyright (C) 1992,1993,1994,1997 |
7 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
8 | Australia. E-mail billm@suburbia.net |
11 +---------------------------------------------------------------------------*/
13 #include "fpu_system.h"
14 #include "exception.h"
17 #include "reg_constant.h"
19 static void fchs(FPU_REG
*st0_ptr
, u_char st0tag
)
21 if (st0tag
^ TAG_Empty
) {
22 signbyte(st0_ptr
) ^= SIGN_NEG
;
25 FPU_stack_underflow();
28 static void fabs(FPU_REG
*st0_ptr
, u_char st0tag
)
30 if (st0tag
^ TAG_Empty
) {
34 FPU_stack_underflow();
37 static void ftst_(FPU_REG
*st0_ptr
, u_char st0tag
)
44 if (getsign(st0_ptr
) == SIGN_POS
)
50 switch (FPU_Special(st0_ptr
)) {
52 if (getsign(st0_ptr
) == SIGN_POS
)
56 if (denormal_operand() < 0) {
59 if (getsign(st0_ptr
) == SIGN_POS
)
61 #endif /* PECULIAR_486 */
66 setcc(SW_C0
| SW_C2
| SW_C3
); /* Operand is not comparable */
67 EXCEPTION(EX_Invalid
);
70 if (getsign(st0_ptr
) == SIGN_POS
)
76 setcc(SW_C0
| SW_C2
| SW_C3
); /* Operand is not comparable */
77 EXCEPTION(EX_INTERNAL
| 0x14);
82 setcc(SW_C0
| SW_C2
| SW_C3
);
83 EXCEPTION(EX_StackUnder
);
88 static void fxam(FPU_REG
*st0_ptr
, u_char st0tag
)
102 switch (FPU_Special(st0_ptr
)) {
104 c
= SW_C2
| SW_C3
; /* Denormal */
107 /* We also use NaN for unsupported types. */
108 if ((st0_ptr
->sigh
& 0x80000000)
109 && (exponent(st0_ptr
) == EXP_OVER
))
117 if (getsign(st0_ptr
) == SIGN_NEG
)
122 static FUNC_ST0
const fp_etc_table
[] = {
123 fchs
, fabs
, (FUNC_ST0
) FPU_illegal
, (FUNC_ST0
) FPU_illegal
,
124 ftst_
, fxam
, (FUNC_ST0
) FPU_illegal
, (FUNC_ST0
) FPU_illegal
129 (fp_etc_table
[FPU_rm
]) (&st(0), FPU_gettag0());