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"
20 static void fchs(FPU_REG
*st0_ptr
, u_char st0tag
)
22 if ( st0tag
^ TAG_Empty
)
24 signbyte(st0_ptr
) ^= SIGN_NEG
;
28 FPU_stack_underflow();
32 static void fabs(FPU_REG
*st0_ptr
, u_char st0tag
)
34 if ( st0tag
^ TAG_Empty
)
40 FPU_stack_underflow();
44 static void ftst_(FPU_REG
*st0_ptr
, u_char st0tag
)
52 if (getsign(st0_ptr
) == SIGN_POS
)
58 switch ( FPU_Special(st0_ptr
) )
61 if (getsign(st0_ptr
) == SIGN_POS
)
65 if ( denormal_operand() < 0 )
69 if (getsign(st0_ptr
) == SIGN_POS
)
71 #endif /* PECULIAR_486 */
76 setcc(SW_C0
|SW_C2
|SW_C3
); /* Operand is not comparable */
77 EXCEPTION(EX_Invalid
);
80 if (getsign(st0_ptr
) == SIGN_POS
)
86 setcc(SW_C0
|SW_C2
|SW_C3
); /* Operand is not comparable */
87 EXCEPTION(EX_INTERNAL
|0x14);
92 setcc(SW_C0
|SW_C2
|SW_C3
);
93 EXCEPTION(EX_StackUnder
);
99 static void fxam(FPU_REG
*st0_ptr
, u_char st0tag
)
114 switch ( FPU_Special(st0_ptr
) )
117 c
= SW_C2
|SW_C3
; /* Denormal */
120 /* We also use NaN for unsupported types. */
121 if ( (st0_ptr
->sigh
& 0x80000000) && (exponent(st0_ptr
) == EXP_OVER
) )
129 if ( getsign(st0_ptr
) == SIGN_NEG
)
135 static FUNC_ST0
const fp_etc_table
[] = {
136 fchs
, fabs
, (FUNC_ST0
)FPU_illegal
, (FUNC_ST0
)FPU_illegal
,
137 ftst_
, fxam
, (FUNC_ST0
)FPU_illegal
, (FUNC_ST0
)FPU_illegal
142 (fp_etc_table
[FPU_rm
])(&st(0), FPU_gettag0());