Merge branch 'master' of git://git.qemu.org/qemu
[qemu/mdroth.git] / linux-user / arm / nwfpe / single_cpdo.c
blob26168e2201d067988e1f14474e0086b360a0a4f1
1 /*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "fpa11.h"
22 #include "softfloat.h"
23 #include "fpopcode.h"
25 float32 float32_exp(float32 Fm);
26 float32 float32_ln(float32 Fm);
27 float32 float32_sin(float32 rFm);
28 float32 float32_cos(float32 rFm);
29 float32 float32_arcsin(float32 rFm);
30 float32 float32_arctan(float32 rFm);
31 float32 float32_log(float32 rFm);
32 float32 float32_tan(float32 rFm);
33 float32 float32_arccos(float32 rFm);
34 float32 float32_pow(float32 rFn,float32 rFm);
35 float32 float32_pol(float32 rFn,float32 rFm);
37 unsigned int SingleCPDO(const unsigned int opcode)
39 FPA11 *fpa11 = GET_FPA11();
40 float32 rFm, rFn = float32_zero;
41 unsigned int Fd, Fm, Fn, nRc = 1;
43 Fm = getFm(opcode);
44 if (CONSTANT_FM(opcode))
46 rFm = getSingleConstant(Fm);
48 else
50 switch (fpa11->fType[Fm])
52 case typeSingle:
53 rFm = fpa11->fpreg[Fm].fSingle;
54 break;
56 default: return 0;
60 if (!MONADIC_INSTRUCTION(opcode))
62 Fn = getFn(opcode);
63 switch (fpa11->fType[Fn])
65 case typeSingle:
66 rFn = fpa11->fpreg[Fn].fSingle;
67 break;
69 default: return 0;
73 Fd = getFd(opcode);
74 switch (opcode & MASK_ARITHMETIC_OPCODE)
76 /* dyadic opcodes */
77 case ADF_CODE:
78 fpa11->fpreg[Fd].fSingle = float32_add(rFn,rFm, &fpa11->fp_status);
79 break;
81 case MUF_CODE:
82 case FML_CODE:
83 fpa11->fpreg[Fd].fSingle = float32_mul(rFn,rFm, &fpa11->fp_status);
84 break;
86 case SUF_CODE:
87 fpa11->fpreg[Fd].fSingle = float32_sub(rFn,rFm, &fpa11->fp_status);
88 break;
90 case RSF_CODE:
91 fpa11->fpreg[Fd].fSingle = float32_sub(rFm,rFn, &fpa11->fp_status);
92 break;
94 case DVF_CODE:
95 case FDV_CODE:
96 fpa11->fpreg[Fd].fSingle = float32_div(rFn,rFm, &fpa11->fp_status);
97 break;
99 case RDF_CODE:
100 case FRD_CODE:
101 fpa11->fpreg[Fd].fSingle = float32_div(rFm,rFn, &fpa11->fp_status);
102 break;
104 #if 0
105 case POW_CODE:
106 fpa11->fpreg[Fd].fSingle = float32_pow(rFn,rFm);
107 break;
109 case RPW_CODE:
110 fpa11->fpreg[Fd].fSingle = float32_pow(rFm,rFn);
111 break;
112 #endif
114 case RMF_CODE:
115 fpa11->fpreg[Fd].fSingle = float32_rem(rFn,rFm, &fpa11->fp_status);
116 break;
118 #if 0
119 case POL_CODE:
120 fpa11->fpreg[Fd].fSingle = float32_pol(rFn,rFm);
121 break;
122 #endif
124 /* monadic opcodes */
125 case MVF_CODE:
126 fpa11->fpreg[Fd].fSingle = rFm;
127 break;
129 case MNF_CODE:
130 fpa11->fpreg[Fd].fSingle = float32_chs(rFm);
131 break;
133 case ABS_CODE:
134 fpa11->fpreg[Fd].fSingle = float32_abs(rFm);
135 break;
137 case RND_CODE:
138 case URD_CODE:
139 fpa11->fpreg[Fd].fSingle = float32_round_to_int(rFm, &fpa11->fp_status);
140 break;
142 case SQT_CODE:
143 fpa11->fpreg[Fd].fSingle = float32_sqrt(rFm, &fpa11->fp_status);
144 break;
146 #if 0
147 case LOG_CODE:
148 fpa11->fpreg[Fd].fSingle = float32_log(rFm);
149 break;
151 case LGN_CODE:
152 fpa11->fpreg[Fd].fSingle = float32_ln(rFm);
153 break;
155 case EXP_CODE:
156 fpa11->fpreg[Fd].fSingle = float32_exp(rFm);
157 break;
159 case SIN_CODE:
160 fpa11->fpreg[Fd].fSingle = float32_sin(rFm);
161 break;
163 case COS_CODE:
164 fpa11->fpreg[Fd].fSingle = float32_cos(rFm);
165 break;
167 case TAN_CODE:
168 fpa11->fpreg[Fd].fSingle = float32_tan(rFm);
169 break;
171 case ASN_CODE:
172 fpa11->fpreg[Fd].fSingle = float32_arcsin(rFm);
173 break;
175 case ACS_CODE:
176 fpa11->fpreg[Fd].fSingle = float32_arccos(rFm);
177 break;
179 case ATN_CODE:
180 fpa11->fpreg[Fd].fSingle = float32_arctan(rFm);
181 break;
182 #endif
184 case NRM_CODE:
185 break;
187 default:
189 nRc = 0;
193 if (0 != nRc) fpa11->fType[Fd] = typeSingle;
194 return nRc;
197 #if 0
198 float32 float32_exp(float32 Fm)
200 //series
203 float32 float32_ln(float32 Fm)
205 //series
208 float32 float32_sin(float32 rFm)
210 //series
213 float32 float32_cos(float32 rFm)
215 //series
218 float32 float32_arcsin(float32 rFm)
220 //series
223 float32 float32_arctan(float32 rFm)
225 //series
228 float32 float32_arccos(float32 rFm)
230 //return float32_sub(halfPi,float32_arcsin(rFm));
233 float32 float32_log(float32 rFm)
235 return float32_div(float32_ln(rFm),getSingleConstant(7));
238 float32 float32_tan(float32 rFm)
240 return float32_div(float32_sin(rFm),float32_cos(rFm));
243 float32 float32_pow(float32 rFn,float32 rFm)
245 return float32_exp(float32_mul(rFm,float32_ln(rFn)));
248 float32 float32_pol(float32 rFn,float32 rFm)
250 return float32_arctan(float32_div(rFn,rFm));
252 #endif