* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-0.99 / drivers / FPU-emu / fpu_etc.c
blobb7e1154cbd3e49a5cf5ff9d0c294a87de1b73dd5
1 /*---------------------------------------------------------------------------+
2 | fpu_etc.c |
3 | |
4 | Implement a few FPU instructions. |
5 | |
6 | Copyright (C) 1992,1993,1994 |
7 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
8 | Australia. E-mail billm@vaxc.cc.monash.edu.au |
9 | |
10 | |
11 +---------------------------------------------------------------------------*/
13 #include "fpu_system.h"
14 #include "exception.h"
15 #include "fpu_emu.h"
16 #include "status_w.h"
17 #include "reg_constant.h"
20 static void fchs(void)
22 if ( NOT_EMPTY_0 )
24 FPU_st0_ptr->sign ^= SIGN_POS^SIGN_NEG;
25 clear_C1();
27 else
28 stack_underflow();
31 static void fabs(void)
33 if ( FPU_st0_tag ^ TW_Empty )
35 FPU_st0_ptr->sign = SIGN_POS;
36 clear_C1();
38 else
39 stack_underflow();
43 static void ftst_(void)
45 switch (FPU_st0_tag)
47 case TW_Zero:
48 setcc(SW_C3);
49 break;
50 case TW_Valid:
51 if (FPU_st0_ptr->sign == SIGN_POS)
52 setcc(0);
53 else
54 setcc(SW_C0);
56 #ifdef DENORM_OPERAND
57 if ( (FPU_st0_ptr->exp <= EXP_UNDER) && (denormal_operand()) )
59 #ifdef PECULIAR_486
60 /* This is wierd! */
61 if (FPU_st0_ptr->sign == SIGN_POS)
62 setcc(SW_C3);
63 #endif PECULIAR_486
64 return;
66 #endif DENORM_OPERAND
68 break;
69 case TW_NaN:
70 setcc(SW_C0|SW_C2|SW_C3); /* Operand is not comparable */
71 EXCEPTION(EX_Invalid);
72 break;
73 case TW_Infinity:
74 if (FPU_st0_ptr->sign == SIGN_POS)
75 setcc(0);
76 else
77 setcc(SW_C0);
78 break;
79 case TW_Empty:
80 setcc(SW_C0|SW_C2|SW_C3);
81 EXCEPTION(EX_StackUnder);
82 break;
83 default:
84 setcc(SW_C0|SW_C2|SW_C3); /* Operand is not comparable */
85 EXCEPTION(EX_INTERNAL|0x14);
86 break;
90 static void fxam(void)
92 int c=0;
93 switch (FPU_st0_tag)
95 case TW_Empty:
96 c = SW_C3|SW_C0;
97 break;
98 case TW_Zero:
99 c = SW_C3;
100 break;
101 case TW_Valid:
102 /* This will need to be changed if TW_Denormal is ever used. */
103 if ( FPU_st0_ptr->exp <= EXP_UNDER )
104 c = SW_C2|SW_C3; /* Denormal */
105 else
106 c = SW_C2;
107 break;
108 case TW_NaN:
109 c = SW_C0;
110 break;
111 case TW_Infinity:
112 c = SW_C2|SW_C0;
113 break;
115 if (FPU_st0_ptr->sign == SIGN_NEG)
116 c |= SW_C1;
117 setcc(c);
120 static FUNC const fp_etc_table[] = {
121 fchs, fabs, FPU_illegal, FPU_illegal, ftst_, fxam, FPU_illegal, FPU_illegal
124 void fp_etc()
126 (fp_etc_table[FPU_rm])();