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 if (FPU_st0_ptr->sign == SIGN_POS)
52 setcc(0);
53 else
54 setcc(SW_C0);
55 break;
56 case TW_NaN:
57 setcc(SW_C2);
58 EXCEPTION(EX_Invalid);
59 break;
60 case TW_Infinity:
61 if (FPU_st0_ptr->sign == SIGN_POS)
62 setcc(0);
63 else
64 setcc(SW_C3);
65
66 EXCEPTION(EX_Invalid);
67 break;
68 case TW_Empty:
69 setcc(SW_C0|SW_C2|SW_C3);
70 EXCEPTION(EX_StackUnder);
71 break;
72 default:
73 setcc(SW_C2);
74 EXCEPTION(EX_INTERNAL|0x14);
75 break;
76 }
77 }
78
79 static void fxam(void)
80 {
81 int c=0;
82 switch (FPU_st0_tag)
83 {
84 case TW_Empty:
85 c = SW_C3|SW_C0;
86 break;
87 case TW_Zero:
88 c = SW_C3;
89 break;
90 case TW_Valid:
91 if (FPU_st0_ptr->sigh & 0x80000000)
92 c = SW_C2;
93 else
94 c = SW_C3|SW_C2;
95 break;
96 case TW_NaN:
97 c = SW_C0;
98 break;
99 case TW_Infinity:
100 c = SW_C2|SW_C0;
101 break;
102 }
103 if (FPU_st0_ptr->sign == SIGN_NEG)
104 c |= SW_C1;
105 setcc(c);
106 }
107
108 static FUNC fp_etc_table[] = {
109 fchs, fabs, Un_impl, Un_impl, ftst_, fxam, Un_impl, Un_impl
110 };
111
112 void fp_etc()
113 {
114 (fp_etc_table[FPU_rm])();
115 }