root / target-arm / nwfpe / single_cpdo.c @ ce05c323
History | View | Annotate | Download (5.4 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 | float32 float32_exp(float32 Fm); |
27 | 00406dff | bellard | float32 float32_ln(float32 Fm); |
28 | 00406dff | bellard | float32 float32_sin(float32 rFm); |
29 | 00406dff | bellard | float32 float32_cos(float32 rFm); |
30 | 00406dff | bellard | float32 float32_arcsin(float32 rFm); |
31 | 00406dff | bellard | float32 float32_arctan(float32 rFm); |
32 | 00406dff | bellard | float32 float32_log(float32 rFm); |
33 | 00406dff | bellard | float32 float32_tan(float32 rFm); |
34 | 00406dff | bellard | float32 float32_arccos(float32 rFm); |
35 | 00406dff | bellard | float32 float32_pow(float32 rFn,float32 rFm); |
36 | 00406dff | bellard | float32 float32_pol(float32 rFn,float32 rFm); |
37 | 00406dff | bellard | |
38 | 00406dff | bellard | unsigned int SingleCPDO(const unsigned int opcode) |
39 | 00406dff | bellard | { |
40 | 00406dff | bellard | FPA11 *fpa11 = GET_FPA11(); |
41 | 526ff7de | bellard | float32 rFm, rFn = 0;
|
42 | 00406dff | bellard | unsigned int Fd, Fm, Fn, nRc = 1; |
43 | 00406dff | bellard | |
44 | 00406dff | bellard | Fm = getFm(opcode); |
45 | 00406dff | bellard | if (CONSTANT_FM(opcode))
|
46 | 00406dff | bellard | { |
47 | 00406dff | bellard | rFm = getSingleConstant(Fm); |
48 | 00406dff | bellard | } |
49 | 00406dff | bellard | else
|
50 | 00406dff | bellard | { |
51 | 00406dff | bellard | switch (fpa11->fType[Fm])
|
52 | 00406dff | bellard | { |
53 | 00406dff | bellard | case typeSingle:
|
54 | 00406dff | bellard | rFm = fpa11->fpreg[Fm].fSingle; |
55 | 00406dff | bellard | break;
|
56 | 00406dff | bellard | |
57 | 00406dff | bellard | default: return 0; |
58 | 00406dff | bellard | } |
59 | 00406dff | bellard | } |
60 | 00406dff | bellard | |
61 | 00406dff | bellard | if (!MONADIC_INSTRUCTION(opcode))
|
62 | 00406dff | bellard | { |
63 | 00406dff | bellard | Fn = getFn(opcode); |
64 | 00406dff | bellard | switch (fpa11->fType[Fn])
|
65 | 00406dff | bellard | { |
66 | 00406dff | bellard | case typeSingle:
|
67 | 00406dff | bellard | rFn = fpa11->fpreg[Fn].fSingle; |
68 | 00406dff | bellard | break;
|
69 | 00406dff | bellard | |
70 | 00406dff | bellard | default: return 0; |
71 | 00406dff | bellard | } |
72 | 00406dff | bellard | } |
73 | 00406dff | bellard | |
74 | 00406dff | bellard | Fd = getFd(opcode); |
75 | 00406dff | bellard | switch (opcode & MASK_ARITHMETIC_OPCODE)
|
76 | 00406dff | bellard | { |
77 | 00406dff | bellard | /* dyadic opcodes */
|
78 | 00406dff | bellard | case ADF_CODE:
|
79 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_add(rFn,rFm, &fpa11->fp_status); |
80 | 00406dff | bellard | break;
|
81 | 00406dff | bellard | |
82 | 00406dff | bellard | case MUF_CODE:
|
83 | 00406dff | bellard | case FML_CODE:
|
84 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_mul(rFn,rFm, &fpa11->fp_status); |
85 | 00406dff | bellard | break;
|
86 | 00406dff | bellard | |
87 | 00406dff | bellard | case SUF_CODE:
|
88 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_sub(rFn,rFm, &fpa11->fp_status); |
89 | 00406dff | bellard | break;
|
90 | 00406dff | bellard | |
91 | 00406dff | bellard | case RSF_CODE:
|
92 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_sub(rFm,rFn, &fpa11->fp_status); |
93 | 00406dff | bellard | break;
|
94 | 00406dff | bellard | |
95 | 00406dff | bellard | case DVF_CODE:
|
96 | 00406dff | bellard | case FDV_CODE:
|
97 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_div(rFn,rFm, &fpa11->fp_status); |
98 | 00406dff | bellard | break;
|
99 | 00406dff | bellard | |
100 | 00406dff | bellard | case RDF_CODE:
|
101 | 00406dff | bellard | case FRD_CODE:
|
102 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_div(rFm,rFn, &fpa11->fp_status); |
103 | 00406dff | bellard | break;
|
104 | 00406dff | bellard | |
105 | 00406dff | bellard | #if 0
|
106 | 00406dff | bellard | case POW_CODE:
|
107 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_pow(rFn,rFm);
|
108 | 00406dff | bellard | break;
|
109 | 00406dff | bellard | |
110 | 00406dff | bellard | case RPW_CODE:
|
111 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_pow(rFm,rFn);
|
112 | 00406dff | bellard | break;
|
113 | 00406dff | bellard | #endif
|
114 | 00406dff | bellard | |
115 | 00406dff | bellard | case RMF_CODE:
|
116 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_rem(rFn,rFm, &fpa11->fp_status); |
117 | 00406dff | bellard | break;
|
118 | 00406dff | bellard | |
119 | 00406dff | bellard | #if 0
|
120 | 00406dff | bellard | case POL_CODE:
|
121 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_pol(rFn,rFm);
|
122 | 00406dff | bellard | break;
|
123 | 00406dff | bellard | #endif
|
124 | 00406dff | bellard | |
125 | 00406dff | bellard | /* monadic opcodes */
|
126 | 00406dff | bellard | case MVF_CODE:
|
127 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = rFm; |
128 | 00406dff | bellard | break;
|
129 | 00406dff | bellard | |
130 | 00406dff | bellard | case MNF_CODE:
|
131 | 00406dff | bellard | rFm ^= 0x80000000;
|
132 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = rFm; |
133 | 00406dff | bellard | break;
|
134 | 00406dff | bellard | |
135 | 00406dff | bellard | case ABS_CODE:
|
136 | 00406dff | bellard | rFm &= 0x7fffffff;
|
137 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = rFm; |
138 | 00406dff | bellard | break;
|
139 | 00406dff | bellard | |
140 | 00406dff | bellard | case RND_CODE:
|
141 | 00406dff | bellard | case URD_CODE:
|
142 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_round_to_int(rFm, &fpa11->fp_status); |
143 | 00406dff | bellard | break;
|
144 | 00406dff | bellard | |
145 | 00406dff | bellard | case SQT_CODE:
|
146 | 20495218 | bellard | fpa11->fpreg[Fd].fSingle = float32_sqrt(rFm, &fpa11->fp_status); |
147 | 00406dff | bellard | break;
|
148 | 00406dff | bellard | |
149 | 00406dff | bellard | #if 0
|
150 | 00406dff | bellard | case LOG_CODE:
|
151 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_log(rFm);
|
152 | 00406dff | bellard | break;
|
153 | 00406dff | bellard | |
154 | 00406dff | bellard | case LGN_CODE:
|
155 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_ln(rFm);
|
156 | 00406dff | bellard | break;
|
157 | 00406dff | bellard | |
158 | 00406dff | bellard | case EXP_CODE:
|
159 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_exp(rFm);
|
160 | 00406dff | bellard | break;
|
161 | 00406dff | bellard | |
162 | 00406dff | bellard | case SIN_CODE:
|
163 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_sin(rFm);
|
164 | 00406dff | bellard | break;
|
165 | 00406dff | bellard | |
166 | 00406dff | bellard | case COS_CODE:
|
167 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_cos(rFm);
|
168 | 00406dff | bellard | break;
|
169 | 00406dff | bellard | |
170 | 00406dff | bellard | case TAN_CODE:
|
171 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_tan(rFm);
|
172 | 00406dff | bellard | break;
|
173 | 00406dff | bellard | |
174 | 00406dff | bellard | case ASN_CODE:
|
175 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_arcsin(rFm);
|
176 | 00406dff | bellard | break;
|
177 | 00406dff | bellard | |
178 | 00406dff | bellard | case ACS_CODE:
|
179 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_arccos(rFm);
|
180 | 00406dff | bellard | break;
|
181 | 00406dff | bellard | |
182 | 00406dff | bellard | case ATN_CODE:
|
183 | 00406dff | bellard | fpa11->fpreg[Fd].fSingle = float32_arctan(rFm);
|
184 | 00406dff | bellard | break;
|
185 | 00406dff | bellard | #endif
|
186 | 00406dff | bellard | |
187 | 00406dff | bellard | case NRM_CODE:
|
188 | 00406dff | bellard | break;
|
189 | 00406dff | bellard | |
190 | 00406dff | bellard | default:
|
191 | 00406dff | bellard | { |
192 | 00406dff | bellard | nRc = 0;
|
193 | 00406dff | bellard | } |
194 | 00406dff | bellard | } |
195 | 00406dff | bellard | |
196 | 00406dff | bellard | if (0 != nRc) fpa11->fType[Fd] = typeSingle; |
197 | 00406dff | bellard | return nRc;
|
198 | 00406dff | bellard | } |
199 | 00406dff | bellard | |
200 | 00406dff | bellard | #if 0
|
201 | 00406dff | bellard | float32 float32_exp(float32 Fm)
|
202 | 00406dff | bellard | {
|
203 | 00406dff | bellard | //series
|
204 | 00406dff | bellard | }
|
205 | 00406dff | bellard | |
206 | 00406dff | bellard | float32 float32_ln(float32 Fm)
|
207 | 00406dff | bellard | {
|
208 | 00406dff | bellard | //series
|
209 | 00406dff | bellard | }
|
210 | 00406dff | bellard | |
211 | 00406dff | bellard | float32 float32_sin(float32 rFm)
|
212 | 00406dff | bellard | {
|
213 | 00406dff | bellard | //series
|
214 | 00406dff | bellard | }
|
215 | 00406dff | bellard | |
216 | 00406dff | bellard | float32 float32_cos(float32 rFm)
|
217 | 00406dff | bellard | {
|
218 | 00406dff | bellard | //series
|
219 | 00406dff | bellard | }
|
220 | 00406dff | bellard | |
221 | 00406dff | bellard | float32 float32_arcsin(float32 rFm)
|
222 | 00406dff | bellard | {
|
223 | 00406dff | bellard | //series
|
224 | 00406dff | bellard | }
|
225 | 00406dff | bellard | |
226 | 00406dff | bellard | float32 float32_arctan(float32 rFm)
|
227 | 00406dff | bellard | {
|
228 | 00406dff | bellard | //series
|
229 | 00406dff | bellard | }
|
230 | 00406dff | bellard | |
231 | 00406dff | bellard | float32 float32_arccos(float32 rFm)
|
232 | 00406dff | bellard | {
|
233 | 00406dff | bellard | //return float32_sub(halfPi,float32_arcsin(rFm));
|
234 | 00406dff | bellard | }
|
235 | 00406dff | bellard | |
236 | 00406dff | bellard | float32 float32_log(float32 rFm)
|
237 | 00406dff | bellard | {
|
238 | 00406dff | bellard | return float32_div(float32_ln(rFm),getSingleConstant(7));
|
239 | 00406dff | bellard | }
|
240 | 00406dff | bellard | |
241 | 00406dff | bellard | float32 float32_tan(float32 rFm)
|
242 | 00406dff | bellard | {
|
243 | 00406dff | bellard | return float32_div(float32_sin(rFm),float32_cos(rFm));
|
244 | 00406dff | bellard | }
|
245 | 00406dff | bellard | |
246 | 00406dff | bellard | float32 float32_pow(float32 rFn,float32 rFm)
|
247 | 00406dff | bellard | {
|
248 | 00406dff | bellard | return float32_exp(float32_mul(rFm,float32_ln(rFn)));
|
249 | 00406dff | bellard | }
|
250 | 00406dff | bellard | |
251 | 00406dff | bellard | float32 float32_pol(float32 rFn,float32 rFm)
|
252 | 00406dff | bellard | {
|
253 | 00406dff | bellard | return float32_arctan(float32_div(rFn,rFm));
|
254 | 00406dff | bellard | }
|
255 | 00406dff | bellard | #endif |