root / target-arm / nwfpe / extended_cpdo.c @ 1d6e34fd
History | View | Annotate | Download (5.9 kB)
1 | 00406dff | bellard | /*
|
---|---|---|---|
2 | 00406dff | bellard | NetWinder Floating Point Emulator
|
3 | 00406dff | bellard | (c) Rebel.COM, 1998,1999
|
4 | 00406dff | bellard | |
5 | 00406dff | bellard | Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
|
6 | 00406dff | bellard | |
7 | 00406dff | bellard | This program is free software; you can redistribute it and/or modify
|
8 | 00406dff | bellard | it under the terms of the GNU General Public License as published by
|
9 | 00406dff | bellard | the Free Software Foundation; either version 2 of the License, or
|
10 | 00406dff | bellard | (at your option) any later version.
|
11 | 00406dff | bellard | |
12 | 00406dff | bellard | This program is distributed in the hope that it will be useful,
|
13 | 00406dff | bellard | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 00406dff | bellard | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 | 00406dff | bellard | GNU General Public License for more details.
|
16 | 00406dff | bellard | |
17 | 00406dff | bellard | You should have received a copy of the GNU General Public License
|
18 | 00406dff | bellard | along with this program; if not, write to the Free Software
|
19 | 00406dff | bellard | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
20 | 00406dff | bellard | */
|
21 | 00406dff | bellard | |
22 | 00406dff | bellard | #include "fpa11.h" |
23 | 00406dff | bellard | #include "softfloat.h" |
24 | 00406dff | bellard | #include "fpopcode.h" |
25 | 00406dff | bellard | |
26 | 00406dff | bellard | floatx80 floatx80_exp(floatx80 Fm); |
27 | 00406dff | bellard | floatx80 floatx80_ln(floatx80 Fm); |
28 | 00406dff | bellard | floatx80 floatx80_sin(floatx80 rFm); |
29 | 00406dff | bellard | floatx80 floatx80_cos(floatx80 rFm); |
30 | 00406dff | bellard | floatx80 floatx80_arcsin(floatx80 rFm); |
31 | 00406dff | bellard | floatx80 floatx80_arctan(floatx80 rFm); |
32 | 00406dff | bellard | floatx80 floatx80_log(floatx80 rFm); |
33 | 00406dff | bellard | floatx80 floatx80_tan(floatx80 rFm); |
34 | 00406dff | bellard | floatx80 floatx80_arccos(floatx80 rFm); |
35 | 00406dff | bellard | floatx80 floatx80_pow(floatx80 rFn,floatx80 rFm); |
36 | 00406dff | bellard | floatx80 floatx80_pol(floatx80 rFn,floatx80 rFm); |
37 | 00406dff | bellard | |
38 | 00406dff | bellard | unsigned int ExtendedCPDO(const unsigned int opcode) |
39 | 00406dff | bellard | { |
40 | 00406dff | bellard | FPA11 *fpa11 = GET_FPA11(); |
41 | 00406dff | bellard | floatx80 rFm, rFn; |
42 | 00406dff | bellard | unsigned int Fd, Fm, Fn, nRc = 1; |
43 | 00406dff | bellard | |
44 | 00406dff | bellard | //printk("ExtendedCPDO(0x%08x)\n",opcode);
|
45 | 00406dff | bellard | |
46 | 00406dff | bellard | Fm = getFm(opcode); |
47 | 00406dff | bellard | if (CONSTANT_FM(opcode))
|
48 | 00406dff | bellard | { |
49 | 00406dff | bellard | rFm = getExtendedConstant(Fm); |
50 | 00406dff | bellard | } |
51 | 00406dff | bellard | else
|
52 | 00406dff | bellard | { |
53 | 00406dff | bellard | switch (fpa11->fType[Fm])
|
54 | 00406dff | bellard | { |
55 | 00406dff | bellard | case typeSingle:
|
56 | 00406dff | bellard | rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle); |
57 | 00406dff | bellard | break;
|
58 | 00406dff | bellard | |
59 | 00406dff | bellard | case typeDouble:
|
60 | 00406dff | bellard | rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble); |
61 | 00406dff | bellard | break;
|
62 | 00406dff | bellard | |
63 | 00406dff | bellard | case typeExtended:
|
64 | 00406dff | bellard | rFm = fpa11->fpreg[Fm].fExtended; |
65 | 00406dff | bellard | break;
|
66 | 00406dff | bellard | |
67 | 00406dff | bellard | default: return 0; |
68 | 00406dff | bellard | } |
69 | 00406dff | bellard | } |
70 | 00406dff | bellard | |
71 | 00406dff | bellard | if (!MONADIC_INSTRUCTION(opcode))
|
72 | 00406dff | bellard | { |
73 | 00406dff | bellard | Fn = getFn(opcode); |
74 | 00406dff | bellard | switch (fpa11->fType[Fn])
|
75 | 00406dff | bellard | { |
76 | 00406dff | bellard | case typeSingle:
|
77 | 00406dff | bellard | rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle); |
78 | 00406dff | bellard | break;
|
79 | 00406dff | bellard | |
80 | 00406dff | bellard | case typeDouble:
|
81 | 00406dff | bellard | rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble); |
82 | 00406dff | bellard | break;
|
83 | 00406dff | bellard | |
84 | 00406dff | bellard | case typeExtended:
|
85 | 00406dff | bellard | rFn = fpa11->fpreg[Fn].fExtended; |
86 | 00406dff | bellard | break;
|
87 | 00406dff | bellard | |
88 | 00406dff | bellard | default: return 0; |
89 | 00406dff | bellard | } |
90 | 00406dff | bellard | } |
91 | 00406dff | bellard | |
92 | 00406dff | bellard | Fd = getFd(opcode); |
93 | 00406dff | bellard | switch (opcode & MASK_ARITHMETIC_OPCODE)
|
94 | 00406dff | bellard | { |
95 | 00406dff | bellard | /* dyadic opcodes */
|
96 | 00406dff | bellard | case ADF_CODE:
|
97 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_add(rFn,rFm); |
98 | 00406dff | bellard | break;
|
99 | 00406dff | bellard | |
100 | 00406dff | bellard | case MUF_CODE:
|
101 | 00406dff | bellard | case FML_CODE:
|
102 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_mul(rFn,rFm); |
103 | 00406dff | bellard | break;
|
104 | 00406dff | bellard | |
105 | 00406dff | bellard | case SUF_CODE:
|
106 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_sub(rFn,rFm); |
107 | 00406dff | bellard | break;
|
108 | 00406dff | bellard | |
109 | 00406dff | bellard | case RSF_CODE:
|
110 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_sub(rFm,rFn); |
111 | 00406dff | bellard | break;
|
112 | 00406dff | bellard | |
113 | 00406dff | bellard | case DVF_CODE:
|
114 | 00406dff | bellard | case FDV_CODE:
|
115 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_div(rFn,rFm); |
116 | 00406dff | bellard | break;
|
117 | 00406dff | bellard | |
118 | 00406dff | bellard | case RDF_CODE:
|
119 | 00406dff | bellard | case FRD_CODE:
|
120 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_div(rFm,rFn); |
121 | 00406dff | bellard | break;
|
122 | 00406dff | bellard | |
123 | 00406dff | bellard | #if 0
|
124 | 00406dff | bellard | case POW_CODE:
|
125 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_pow(rFn,rFm);
|
126 | 00406dff | bellard | break;
|
127 | 00406dff | bellard | |
128 | 00406dff | bellard | case RPW_CODE:
|
129 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_pow(rFm,rFn);
|
130 | 00406dff | bellard | break;
|
131 | 00406dff | bellard | #endif
|
132 | 00406dff | bellard | |
133 | 00406dff | bellard | case RMF_CODE:
|
134 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_rem(rFn,rFm); |
135 | 00406dff | bellard | break;
|
136 | 00406dff | bellard | |
137 | 00406dff | bellard | #if 0
|
138 | 00406dff | bellard | case POL_CODE:
|
139 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_pol(rFn,rFm);
|
140 | 00406dff | bellard | break;
|
141 | 00406dff | bellard | #endif
|
142 | 00406dff | bellard | |
143 | 00406dff | bellard | /* monadic opcodes */
|
144 | 00406dff | bellard | case MVF_CODE:
|
145 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = rFm; |
146 | 00406dff | bellard | break;
|
147 | 00406dff | bellard | |
148 | 00406dff | bellard | case MNF_CODE:
|
149 | 00406dff | bellard | rFm.high ^= 0x8000;
|
150 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = rFm; |
151 | 00406dff | bellard | break;
|
152 | 00406dff | bellard | |
153 | 00406dff | bellard | case ABS_CODE:
|
154 | 00406dff | bellard | rFm.high &= 0x7fff;
|
155 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = rFm; |
156 | 00406dff | bellard | break;
|
157 | 00406dff | bellard | |
158 | 00406dff | bellard | case RND_CODE:
|
159 | 00406dff | bellard | case URD_CODE:
|
160 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_round_to_int(rFm); |
161 | 00406dff | bellard | break;
|
162 | 00406dff | bellard | |
163 | 00406dff | bellard | case SQT_CODE:
|
164 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_sqrt(rFm); |
165 | 00406dff | bellard | break;
|
166 | 00406dff | bellard | |
167 | 00406dff | bellard | #if 0
|
168 | 00406dff | bellard | case LOG_CODE:
|
169 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_log(rFm);
|
170 | 00406dff | bellard | break;
|
171 | 00406dff | bellard | |
172 | 00406dff | bellard | case LGN_CODE:
|
173 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_ln(rFm);
|
174 | 00406dff | bellard | break;
|
175 | 00406dff | bellard | |
176 | 00406dff | bellard | case EXP_CODE:
|
177 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_exp(rFm);
|
178 | 00406dff | bellard | break;
|
179 | 00406dff | bellard | |
180 | 00406dff | bellard | case SIN_CODE:
|
181 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_sin(rFm);
|
182 | 00406dff | bellard | break;
|
183 | 00406dff | bellard | |
184 | 00406dff | bellard | case COS_CODE:
|
185 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_cos(rFm);
|
186 | 00406dff | bellard | break;
|
187 | 00406dff | bellard | |
188 | 00406dff | bellard | case TAN_CODE:
|
189 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_tan(rFm);
|
190 | 00406dff | bellard | break;
|
191 | 00406dff | bellard | |
192 | 00406dff | bellard | case ASN_CODE:
|
193 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_arcsin(rFm);
|
194 | 00406dff | bellard | break;
|
195 | 00406dff | bellard | |
196 | 00406dff | bellard | case ACS_CODE:
|
197 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_arccos(rFm);
|
198 | 00406dff | bellard | break;
|
199 | 00406dff | bellard | |
200 | 00406dff | bellard | case ATN_CODE:
|
201 | 00406dff | bellard | fpa11->fpreg[Fd].fExtended = floatx80_arctan(rFm);
|
202 | 00406dff | bellard | break;
|
203 | 00406dff | bellard | #endif
|
204 | 00406dff | bellard | |
205 | 00406dff | bellard | case NRM_CODE:
|
206 | 00406dff | bellard | break;
|
207 | 00406dff | bellard | |
208 | 00406dff | bellard | default:
|
209 | 00406dff | bellard | { |
210 | 00406dff | bellard | nRc = 0;
|
211 | 00406dff | bellard | } |
212 | 00406dff | bellard | } |
213 | 00406dff | bellard | |
214 | 00406dff | bellard | if (0 != nRc) fpa11->fType[Fd] = typeExtended; |
215 | 00406dff | bellard | return nRc;
|
216 | 00406dff | bellard | } |
217 | 00406dff | bellard | |
218 | 00406dff | bellard | #if 0
|
219 | 00406dff | bellard | floatx80 floatx80_exp(floatx80 Fm)
|
220 | 00406dff | bellard | {
|
221 | 00406dff | bellard | //series
|
222 | 00406dff | bellard | }
|
223 | 00406dff | bellard | |
224 | 00406dff | bellard | floatx80 floatx80_ln(floatx80 Fm)
|
225 | 00406dff | bellard | {
|
226 | 00406dff | bellard | //series
|
227 | 00406dff | bellard | }
|
228 | 00406dff | bellard | |
229 | 00406dff | bellard | floatx80 floatx80_sin(floatx80 rFm)
|
230 | 00406dff | bellard | {
|
231 | 00406dff | bellard | //series
|
232 | 00406dff | bellard | }
|
233 | 00406dff | bellard | |
234 | 00406dff | bellard | floatx80 floatx80_cos(floatx80 rFm)
|
235 | 00406dff | bellard | {
|
236 | 00406dff | bellard | //series
|
237 | 00406dff | bellard | }
|
238 | 00406dff | bellard | |
239 | 00406dff | bellard | floatx80 floatx80_arcsin(floatx80 rFm)
|
240 | 00406dff | bellard | {
|
241 | 00406dff | bellard | //series
|
242 | 00406dff | bellard | }
|
243 | 00406dff | bellard | |
244 | 00406dff | bellard | floatx80 floatx80_arctan(floatx80 rFm)
|
245 | 00406dff | bellard | {
|
246 | 00406dff | bellard | //series
|
247 | 00406dff | bellard | }
|
248 | 00406dff | bellard | |
249 | 00406dff | bellard | floatx80 floatx80_log(floatx80 rFm)
|
250 | 00406dff | bellard | {
|
251 | 00406dff | bellard | return floatx80_div(floatx80_ln(rFm),getExtendedConstant(7));
|
252 | 00406dff | bellard | }
|
253 | 00406dff | bellard | |
254 | 00406dff | bellard | floatx80 floatx80_tan(floatx80 rFm)
|
255 | 00406dff | bellard | {
|
256 | 00406dff | bellard | return floatx80_div(floatx80_sin(rFm),floatx80_cos(rFm));
|
257 | 00406dff | bellard | }
|
258 | 00406dff | bellard | |
259 | 00406dff | bellard | floatx80 floatx80_arccos(floatx80 rFm)
|
260 | 00406dff | bellard | {
|
261 | 00406dff | bellard | //return floatx80_sub(halfPi,floatx80_arcsin(rFm));
|
262 | 00406dff | bellard | }
|
263 | 00406dff | bellard | |
264 | 00406dff | bellard | floatx80 floatx80_pow(floatx80 rFn,floatx80 rFm)
|
265 | 00406dff | bellard | {
|
266 | 00406dff | bellard | return floatx80_exp(floatx80_mul(rFm,floatx80_ln(rFn)));
|
267 | 00406dff | bellard | }
|
268 | 00406dff | bellard | |
269 | 00406dff | bellard | floatx80 floatx80_pol(floatx80 rFn,floatx80 rFm)
|
270 | 00406dff | bellard | {
|
271 | 00406dff | bellard | return floatx80_arctan(floatx80_div(rFn,rFm));
|
272 | 00406dff | bellard | }
|
273 | 00406dff | bellard | #endif |