This source file includes following definitions.
- fchs
- fabs
- ftst_
- fxam
- fp_etc
1
2
3
4
5
6
7
8
9
10
11
12
13 #include "fpu_system.h"
14 #include "exception.h"
15 #include "fpu_emu.h"
16 #include "status_w.h"
17 #include "reg_constant.h"
18
19
20 static void fchs(void)
21 {
22 if ( NOT_EMPTY_0 )
23 {
24 FPU_st0_ptr->sign ^= SIGN_POS^SIGN_NEG;
25 status_word &= ~SW_C1;
26 }
27 else
28 stack_underflow();
29 }
30
31 static void fabs(void)
32 {
33 if ( FPU_st0_tag ^ TW_Empty )
34 {
35 FPU_st0_ptr->sign = SIGN_POS;
36 status_word &= ~SW_C1;
37 }
38 else
39 stack_underflow();
40 }
41
42
43 static void ftst_(void)
44 {
45 switch (FPU_st0_tag)
46 {
47 case TW_Zero:
48 setcc(SW_C3);
49 break;
50 case TW_Valid:
51
52 #ifdef DENORM_OPERAND
53 if ( (FPU_st0_ptr->exp <= EXP_UNDER) && (denormal_operand()) )
54 return;
55 #endif DENORM_OPERAND
56
57 if (FPU_st0_ptr->sign == SIGN_POS)
58 setcc(0);
59 else
60 setcc(SW_C0);
61 break;
62 case TW_NaN:
63 setcc(SW_C0|SW_C2|SW_C3);
64 EXCEPTION(EX_Invalid);
65 break;
66 case TW_Infinity:
67 if (FPU_st0_ptr->sign == SIGN_POS)
68 setcc(0);
69 else
70 setcc(SW_C0);
71 EXCEPTION(EX_Invalid);
72 break;
73 case TW_Empty:
74 setcc(SW_C0|SW_C2|SW_C3);
75 EXCEPTION(EX_StackUnder);
76 break;
77 default:
78 setcc(SW_C0|SW_C2|SW_C3);
79 EXCEPTION(EX_INTERNAL|0x14);
80 break;
81 }
82 }
83
84 static void fxam(void)
85 {
86 int c=0;
87 switch (FPU_st0_tag)
88 {
89 case TW_Empty:
90 c = SW_C3|SW_C0;
91 break;
92 case TW_Zero:
93 c = SW_C3;
94 break;
95 case TW_Valid:
96
97 if ( FPU_st0_ptr->exp <= EXP_UNDER )
98 c = SW_C2|SW_C3;
99 else
100 c = SW_C3;
101 break;
102 case TW_NaN:
103 c = SW_C0;
104 break;
105 case TW_Infinity:
106 c = SW_C2|SW_C0;
107 break;
108 }
109 if (FPU_st0_ptr->sign == SIGN_NEG)
110 c |= SW_C1;
111 setcc(c);
112 }
113
114 static FUNC fp_etc_table[] = {
115 fchs, fabs, Un_impl, Un_impl, ftst_, fxam, Un_impl, Un_impl
116 };
117
118 void fp_etc()
119 {
120 (fp_etc_table[FPU_rm])();
121 }