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/>.
22 #include "softfloat.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;
44 if (CONSTANT_FM(opcode
))
46 rFm
= getSingleConstant(Fm
);
50 switch (fpa11
->fType
[Fm
])
53 rFm
= fpa11
->fpreg
[Fm
].fSingle
;
60 if (!MONADIC_INSTRUCTION(opcode
))
63 switch (fpa11
->fType
[Fn
])
66 rFn
= fpa11
->fpreg
[Fn
].fSingle
;
74 switch (opcode
& MASK_ARITHMETIC_OPCODE
)
78 fpa11
->fpreg
[Fd
].fSingle
= float32_add(rFn
,rFm
, &fpa11
->fp_status
);
83 fpa11
->fpreg
[Fd
].fSingle
= float32_mul(rFn
,rFm
, &fpa11
->fp_status
);
87 fpa11
->fpreg
[Fd
].fSingle
= float32_sub(rFn
,rFm
, &fpa11
->fp_status
);
91 fpa11
->fpreg
[Fd
].fSingle
= float32_sub(rFm
,rFn
, &fpa11
->fp_status
);
96 fpa11
->fpreg
[Fd
].fSingle
= float32_div(rFn
,rFm
, &fpa11
->fp_status
);
101 fpa11
->fpreg
[Fd
].fSingle
= float32_div(rFm
,rFn
, &fpa11
->fp_status
);
106 fpa11
->fpreg
[Fd
].fSingle
= float32_pow(rFn
,rFm
);
110 fpa11
->fpreg
[Fd
].fSingle
= float32_pow(rFm
,rFn
);
115 fpa11
->fpreg
[Fd
].fSingle
= float32_rem(rFn
,rFm
, &fpa11
->fp_status
);
120 fpa11
->fpreg
[Fd
].fSingle
= float32_pol(rFn
,rFm
);
124 /* monadic opcodes */
126 fpa11
->fpreg
[Fd
].fSingle
= rFm
;
130 fpa11
->fpreg
[Fd
].fSingle
= float32_chs(rFm
);
134 fpa11
->fpreg
[Fd
].fSingle
= float32_abs(rFm
);
139 fpa11
->fpreg
[Fd
].fSingle
= float32_round_to_int(rFm
, &fpa11
->fp_status
);
143 fpa11
->fpreg
[Fd
].fSingle
= float32_sqrt(rFm
, &fpa11
->fp_status
);
148 fpa11
->fpreg
[Fd
].fSingle
= float32_log(rFm
);
152 fpa11
->fpreg
[Fd
].fSingle
= float32_ln(rFm
);
156 fpa11
->fpreg
[Fd
].fSingle
= float32_exp(rFm
);
160 fpa11
->fpreg
[Fd
].fSingle
= float32_sin(rFm
);
164 fpa11
->fpreg
[Fd
].fSingle
= float32_cos(rFm
);
168 fpa11
->fpreg
[Fd
].fSingle
= float32_tan(rFm
);
172 fpa11
->fpreg
[Fd
].fSingle
= float32_arcsin(rFm
);
176 fpa11
->fpreg
[Fd
].fSingle
= float32_arccos(rFm
);
180 fpa11
->fpreg
[Fd
].fSingle
= float32_arctan(rFm
);
193 if (0 != nRc
) fpa11
->fType
[Fd
] = typeSingle
;
198 float32
float32_exp(float32 Fm
)
203 float32
float32_ln(float32 Fm
)
208 float32
float32_sin(float32 rFm
)
213 float32
float32_cos(float32 rFm
)
218 float32
float32_arcsin(float32 rFm
)
223 float32
float32_arctan(float32 rFm
)
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
));