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