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 #include "fpu_system.h"
13 #include "exception.h"
14 #include "fpu_emu.h"
15 #include "status_w.h"
16
17
18
19 static void fclex()
20 {
21 status_word &= ~(SW_B|SW_ES|SW_SF|SW_PE|SW_UE|SW_OE|SW_ZE|SW_DE|SW_IE);
22 FPU_entry_eip = ip_offset;
23 }
24
25
26 void finit()
27 {
28 int r;
29 control_word = 0x037e;
30 status_word = 0;
31 top = 0;
32 for (r = 0; r < 8; r++)
33 {
34 regs[r].sign = 0;
35 regs[r].tag = TW_Empty;
36 regs[r].exp = 0;
37 regs[r].sigh = 0;
38 regs[r].sigl = 0;
39 }
40 FPU_entry_eip = ip_offset;
41 }
42
43 static FUNC finit_table[] = {
44 Un_impl, Un_impl, fclex, finit, Un_impl, Un_impl, Un_impl, Un_impl
45 };
46
47 void finit_()
48 {
49 (finit_table[FPU_rm])();
50 }
51
52
53 static void fstsw_ax()
54 {
55
56 status_word &= ~SW_TOP;
57 status_word |= (top&7) << SW_TOPS;
58
59 *(short *) &FPU_EAX = status_word;
60
61 }
62
63 static FUNC fstsw_table[] = {
64 fstsw_ax, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl
65 };
66
67 void fstsw_()
68 {
69 (fstsw_table[FPU_rm])();
70 }
71
72
73
74 static void fnop()
75 {
76 }
77
78 FUNC fp_nop_table[] = {
79 fnop, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl, Un_impl
80 };
81
82 void fp_nop()
83 {
84 (fp_nop_table[FPU_rm])();
85 }
86
87
88 void fld_i_()
89 {
90 FPU_REG *st_new_ptr;
91
92 if ( STACK_OVERFLOW )
93 { stack_overflow(); return; }
94
95
96 if ( NOT_EMPTY(FPU_rm) )
97 { reg_move(&st(FPU_rm), st_new_ptr); push(); }
98 else
99 {
100 if ( control_word & EX_Invalid )
101 {
102
103 push();
104 stack_underflow();
105 }
106 else
107 EXCEPTION(EX_StackUnder);
108 }
109
110 }
111
112
113 void fxch_i()
114 {
115
116 FPU_REG t;
117 register FPU_REG *sti_ptr = &st(FPU_rm);
118 reg_move(FPU_st0_ptr, &t);
119 reg_move(sti_ptr, FPU_st0_ptr);
120 reg_move(&t, sti_ptr);
121 }
122
123
124 void ffree_()
125 {
126
127 st(FPU_rm).tag = TW_Empty;
128 }
129
130
131 void ffreep()
132 {
133
134 st(FPU_rm).tag = TW_Empty;
135 pop();
136 }
137
138
139 void fst_i_()
140 {
141
142 reg_move(FPU_st0_ptr, &st(FPU_rm));
143 }
144
145
146 void fstp_i()
147 {
148
149 reg_move(FPU_st0_ptr, &st(FPU_rm));
150 pop();
151 }
152