* add p cc
[mascara-docs.git] / i386 / linux / linux-2.3.21 / arch / arm / nwfpe / single_cpdo.c
bloba2a9f6f815b34126fb8d1ebd36b0d3cfe4bc97ba
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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "config.h"
23 #include "milieu.h"
24 #include "softfloat.h"
25 #include "fpopcode.h"
26 #include "fpa11.h"
28 float32 getSingleConstant(unsigned int);
30 float32 float32_exp(float32 Fm);
31 float32 float32_ln(float32 Fm);
32 float32 float32_sin(float32 rFm);
33 float32 float32_cos(float32 rFm);
34 float32 float32_arcsin(float32 rFm);
35 float32 float32_arctan(float32 rFm);
36 float32 float32_log(float32 rFm);
37 float32 float32_tan(float32 rFm);
38 float32 float32_arccos(float32 rFm);
39 float32 float32_pow(float32 rFn,float32 rFm);
40 float32 float32_pol(float32 rFn,float32 rFm);
42 unsigned int SingleCPDO(const unsigned int opcode)
44 float32 rFm, rFn;
45 unsigned int Fd, Fm, Fn, nRc = 1;
47 Fm = getFm(opcode);
48 if (CONSTANT_FM(opcode))
50 rFm = getSingleConstant(Fm);
52 else
54 switch (fpa11->fpreg[Fm].fType)
56 case typeSingle:
57 rFm = fpa11->fpreg[Fm].fValue.fSingle;
58 break;
60 default: return 0;
64 if (!MONADIC_INSTRUCTION(opcode))
66 Fn = getFn(opcode);
67 switch (fpa11->fpreg[Fn].fType)
69 case typeSingle:
70 rFn = fpa11->fpreg[Fn].fValue.fSingle;
71 break;
73 default: return 0;
77 Fd = getFd(opcode);
78 switch (opcode & MASK_ARITHMETIC_OPCODE)
80 /* dyadic opcodes */
81 case ADF_CODE:
82 fpa11->fpreg[Fd].fValue.fSingle = float32_add(rFn,rFm);
83 break;
85 case MUF_CODE:
86 case FML_CODE:
87 fpa11->fpreg[Fd].fValue.fSingle = float32_mul(rFn,rFm);
88 break;
90 case SUF_CODE:
91 fpa11->fpreg[Fd].fValue.fSingle = float32_sub(rFn,rFm);
92 break;
94 case RSF_CODE:
95 fpa11->fpreg[Fd].fValue.fSingle = float32_sub(rFm,rFn);
96 break;
98 case DVF_CODE:
99 case FDV_CODE:
100 fpa11->fpreg[Fd].fValue.fSingle = float32_div(rFn,rFm);
101 break;
103 case RDF_CODE:
104 case FRD_CODE:
105 fpa11->fpreg[Fd].fValue.fSingle = float32_div(rFm,rFn);
106 break;
108 #if 0
109 case POW_CODE:
110 fpa11->fpreg[Fd].fValue.fSingle = float32_pow(rFn,rFm);
111 break;
113 case RPW_CODE:
114 fpa11->fpreg[Fd].fValue.fSingle = float32_pow(rFm,rFn);
115 break;
116 #endif
118 case RMF_CODE:
119 fpa11->fpreg[Fd].fValue.fSingle = float32_rem(rFn,rFm);
120 break;
122 #if 0
123 case POL_CODE:
124 fpa11->fpreg[Fd].fValue.fSingle = float32_pol(rFn,rFm);
125 break;
126 #endif
128 /* monadic opcodes */
129 case MVF_CODE:
130 fpa11->fpreg[Fd].fValue.fSingle = rFm;
131 break;
133 case MNF_CODE:
134 rFm ^= 0x80000000;
135 fpa11->fpreg[Fd].fValue.fSingle = rFm;
136 break;
138 case ABS_CODE:
139 rFm &= 0x7fffffff;
140 fpa11->fpreg[Fd].fValue.fSingle = rFm;
141 break;
143 case RND_CODE:
144 case URD_CODE:
145 fpa11->fpreg[Fd].fValue.fSingle =
146 int32_to_float32(float32_to_int32(rFm));
147 break;
149 case SQT_CODE:
150 fpa11->fpreg[Fd].fValue.fSingle = float32_sqrt(rFm);
151 break;
153 #if 0
154 case LOG_CODE:
155 fpa11->fpreg[Fd].fValue.fSingle = float32_log(rFm);
156 break;
158 case LGN_CODE:
159 fpa11->fpreg[Fd].fValue.fSingle = float32_ln(rFm);
160 break;
162 case EXP_CODE:
163 fpa11->fpreg[Fd].fValue.fSingle = float32_exp(rFm);
164 break;
166 case SIN_CODE:
167 fpa11->fpreg[Fd].fValue.fSingle = float32_sin(rFm);
168 break;
170 case COS_CODE:
171 fpa11->fpreg[Fd].fValue.fSingle = float32_cos(rFm);
172 break;
174 case TAN_CODE:
175 fpa11->fpreg[Fd].fValue.fSingle = float32_tan(rFm);
176 break;
178 case ASN_CODE:
179 fpa11->fpreg[Fd].fValue.fSingle = float32_arcsin(rFm);
180 break;
182 case ACS_CODE:
183 fpa11->fpreg[Fd].fValue.fSingle = float32_arccos(rFm);
184 break;
186 case ATN_CODE:
187 fpa11->fpreg[Fd].fValue.fSingle = float32_arctan(rFm);
188 break;
189 #endif
191 case NRM_CODE:
192 break;
194 default:
196 nRc = 0;
200 if (0 != nRc) fpa11->fpreg[Fd].fType = typeSingle;
201 return nRc;
204 #if 0
205 float32 float32_exp(float32 Fm)
207 //series
210 float32 float32_ln(float32 Fm)
212 //series
215 float32 float32_sin(float32 rFm)
217 //series
220 float32 float32_cos(float32 rFm)
222 //series
225 float32 float32_arcsin(float32 rFm)
227 //series
230 float32 float32_arctan(float32 rFm)
232 //series
235 float32 float32_arccos(float32 rFm)
237 //return float32_sub(halfPi,float32_arcsin(rFm));
240 float32 float32_log(float32 rFm)
242 return float32_div(float32_ln(rFm),getSingleConstant(7));
245 float32 float32_tan(float32 rFm)
247 return float32_div(float32_sin(rFm),float32_cos(rFm));
250 float32 float32_pow(float32 rFn,float32 rFm)
252 return float32_exp(float32_mul(rFm,float32_ln(rFn)));
255 float32 float32_pol(float32 rFn,float32 rFm)
257 return float32_arctan(float32_div(rFn,rFm));
259 #endif