1 // SPDX-License-Identifier: GPL-2.0
2 /*---------------------------------------------------------------------------+
5 | Implement a few FPU instructions. |
7 | Copyright (C) 1992,1993,1994,1997 |
8 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
9 | Australia. E-mail billm@suburbia.net |
12 +---------------------------------------------------------------------------*/
14 #include "fpu_system.h"
15 #include "exception.h"
18 #include "reg_constant.h"
20 static void fchs(FPU_REG
*st0_ptr
, u_char st0tag
)
22 if (st0tag
^ TAG_Empty
) {
23 signbyte(st0_ptr
) ^= SIGN_NEG
;
26 FPU_stack_underflow();
29 static void fabs(FPU_REG
*st0_ptr
, u_char st0tag
)
31 if (st0tag
^ TAG_Empty
) {
35 FPU_stack_underflow();
38 static void ftst_(FPU_REG
*st0_ptr
, u_char st0tag
)
45 if (getsign(st0_ptr
) == SIGN_POS
)
51 switch (FPU_Special(st0_ptr
)) {
53 if (getsign(st0_ptr
) == SIGN_POS
)
57 if (denormal_operand() < 0) {
60 if (getsign(st0_ptr
) == SIGN_POS
)
62 #endif /* PECULIAR_486 */
67 setcc(SW_C0
| SW_C2
| SW_C3
); /* Operand is not comparable */
68 EXCEPTION(EX_Invalid
);
71 if (getsign(st0_ptr
) == SIGN_POS
)
77 setcc(SW_C0
| SW_C2
| SW_C3
); /* Operand is not comparable */
78 EXCEPTION(EX_INTERNAL
| 0x14);
83 setcc(SW_C0
| SW_C2
| SW_C3
);
84 EXCEPTION(EX_StackUnder
);
89 static void fxam(FPU_REG
*st0_ptr
, u_char st0tag
)
103 switch (FPU_Special(st0_ptr
)) {
105 c
= SW_C2
| SW_C3
; /* Denormal */
108 /* We also use NaN for unsupported types. */
109 if ((st0_ptr
->sigh
& 0x80000000)
110 && (exponent(st0_ptr
) == EXP_OVER
))
118 if (getsign(st0_ptr
) == SIGN_NEG
)
123 static FUNC_ST0
const fp_etc_table
[] = {
124 fchs
, fabs
, (FUNC_ST0
) FPU_illegal
, (FUNC_ST0
) FPU_illegal
,
125 ftst_
, fxam
, (FUNC_ST0
) FPU_illegal
, (FUNC_ST0
) FPU_illegal
130 (fp_etc_table
[FPU_rm
]) (&st(0), FPU_gettag0());