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