This source file includes following definitions.
- fclex
- finit
- finit_
- fstsw_ax
- fstsw_
- fnop
- fp_nop
- fld_i_
- fxch_i
- ffree_
- ffreep
- fst_i_
- fstp_i
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
18
19
20 void fclex(void)
21 {
22 status_word &= ~(SW_Backward|SW_Summary|SW_Stack_Fault|SW_Precision|
23 SW_Underflow|SW_Overflow|SW_Zero_Div|SW_Denorm_Op|
24 SW_Invalid);
25 FPU_entry_eip = ip_offset;
26 }
27
28
29 void finit()
30 {
31 int r;
32 control_word = 0x037f;
33 status_word = 0;
34 top = 0;
35 for (r = 0; r < 8; r++)
36 {
37 regs[r].tag = TW_Empty;
38 }
39 FPU_entry_eip = ip_offset = 0;
40 }
41
42 static FUNC finit_table[] = {
43 Un_impl, Un_impl, fclex, finit, Un_impl, Un_impl, Un_impl, Un_impl
44 };
45
46 void finit_()
47 {
48 (finit_table[FPU_rm])();
49 }
50
51
52 static void fstsw_ax(void)
53 {
54
55 status_word &= ~SW_Top;
56 status_word |= (top&7) << SW_Top_Shift;
57
58 *(short *) &FPU_EAX = status_word;
59
60 }
61
62 static FUNC fstsw_table[] = {
63 fstsw_ax, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl
64 };
65
66 void fstsw_()
67 {
68 (fstsw_table[FPU_rm])();
69 }
70
71
72
73 static void fnop(void)
74 {
75 }
76
77 FUNC fp_nop_table[] = {
78 fnop, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl
79 };
80
81 void fp_nop()
82 {
83 (fp_nop_table[FPU_rm])();
84 }
85
86
87 void fld_i_()
88 {
89 FPU_REG *st_new_ptr;
90
91 if ( STACK_OVERFLOW )
92 { stack_overflow(); return; }
93
94
95 if ( NOT_EMPTY(FPU_rm) )
96 { reg_move(&st(FPU_rm), st_new_ptr); push(); }
97 else
98 {
99 if ( control_word & EX_Invalid )
100 {
101
102 push();
103 stack_underflow();
104 }
105 else
106 EXCEPTION(EX_StackUnder);
107 }
108
109 }
110
111
112 void fxch_i()
113 {
114
115 FPU_REG t;
116 register FPU_REG *sti_ptr = &st(FPU_rm);
117
118 if ( FPU_st0_tag == TW_Empty )
119 {
120 if ( sti_ptr->tag == TW_Empty )
121 {
122 stack_underflow();
123 stack_underflow_i(FPU_rm);
124 return;
125 }
126 reg_move(sti_ptr, FPU_st0_ptr);
127 stack_underflow_i(FPU_rm);
128 return;
129 }
130 if ( sti_ptr->tag == TW_Empty )
131 {
132 reg_move(FPU_st0_ptr, sti_ptr);
133 stack_underflow();
134 return;
135 }
136 reg_move(FPU_st0_ptr, &t);
137 reg_move(sti_ptr, FPU_st0_ptr);
138 reg_move(&t, sti_ptr);
139 }
140
141
142 void ffree_()
143 {
144
145 st(FPU_rm).tag = TW_Empty;
146 }
147
148
149 void ffreep()
150 {
151
152 st(FPU_rm).tag = TW_Empty;
153 pop();
154 }
155
156
157 void fst_i_()
158 {
159
160 reg_move(FPU_st0_ptr, &st(FPU_rm));
161 }
162
163
164 void fstp_i()
165 {
166
167 reg_move(FPU_st0_ptr, &st(FPU_rm));
168 pop();
169 }
170