1 // SPDX-License-Identifier: GPL-2.0-or-later
3 NetWinder Floating Point Emulator
4 (c) Rebel.COM, 1998,1999
5 (c) Philip Blundell, 2001
7 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
12 #include "softfloat.h"
15 float32
float32_exp(float32 Fm
);
16 float32
float32_ln(float32 Fm
);
17 float32
float32_sin(float32 rFm
);
18 float32
float32_cos(float32 rFm
);
19 float32
float32_arcsin(float32 rFm
);
20 float32
float32_arctan(float32 rFm
);
21 float32
float32_log(float32 rFm
);
22 float32
float32_tan(float32 rFm
);
23 float32
float32_arccos(float32 rFm
);
24 float32
float32_pow(float32 rFn
, float32 rFm
);
25 float32
float32_pol(float32 rFn
, float32 rFm
);
27 static float32
float32_rsf(struct roundingData
*roundData
, float32 rFn
, float32 rFm
)
29 return float32_sub(roundData
, rFm
, rFn
);
32 static float32
float32_rdv(struct roundingData
*roundData
, float32 rFn
, float32 rFm
)
34 return float32_div(roundData
, rFm
, rFn
);
37 static float32 (*const dyadic_single
[16])(struct roundingData
*, float32 rFn
, float32 rFm
) = {
38 [ADF_CODE
>> 20] = float32_add
,
39 [MUF_CODE
>> 20] = float32_mul
,
40 [SUF_CODE
>> 20] = float32_sub
,
41 [RSF_CODE
>> 20] = float32_rsf
,
42 [DVF_CODE
>> 20] = float32_div
,
43 [RDF_CODE
>> 20] = float32_rdv
,
44 [RMF_CODE
>> 20] = float32_rem
,
46 [FML_CODE
>> 20] = float32_mul
,
47 [FDV_CODE
>> 20] = float32_div
,
48 [FRD_CODE
>> 20] = float32_rdv
,
51 static float32
float32_mvf(struct roundingData
*roundData
, float32 rFm
)
56 static float32
float32_mnf(struct roundingData
*roundData
, float32 rFm
)
58 return rFm
^ 0x80000000;
61 static float32
float32_abs(struct roundingData
*roundData
, float32 rFm
)
63 return rFm
& 0x7fffffff;
66 static float32 (*const monadic_single
[16])(struct roundingData
*, float32 rFm
) = {
67 [MVF_CODE
>> 20] = float32_mvf
,
68 [MNF_CODE
>> 20] = float32_mnf
,
69 [ABS_CODE
>> 20] = float32_abs
,
70 [RND_CODE
>> 20] = float32_round_to_int
,
71 [URD_CODE
>> 20] = float32_round_to_int
,
72 [SQT_CODE
>> 20] = float32_sqrt
,
73 [NRM_CODE
>> 20] = float32_mvf
,
76 unsigned int SingleCPDO(struct roundingData
*roundData
, const unsigned int opcode
, FPREG
* rFd
)
78 FPA11
*fpa11
= GET_FPA11();
80 unsigned int Fm
, opc_mask_shift
;
83 if (CONSTANT_FM(opcode
)) {
84 rFm
= getSingleConstant(Fm
);
85 } else if (fpa11
->fType
[Fm
] == typeSingle
) {
86 rFm
= fpa11
->fpreg
[Fm
].fSingle
;
91 opc_mask_shift
= (opcode
& MASK_ARITHMETIC_OPCODE
) >> 20;
92 if (!MONADIC_INSTRUCTION(opcode
)) {
93 unsigned int Fn
= getFn(opcode
);
96 if (fpa11
->fType
[Fn
] == typeSingle
&&
97 dyadic_single
[opc_mask_shift
]) {
98 rFn
= fpa11
->fpreg
[Fn
].fSingle
;
99 rFd
->fSingle
= dyadic_single
[opc_mask_shift
](roundData
, rFn
, rFm
);
104 if (monadic_single
[opc_mask_shift
]) {
105 rFd
->fSingle
= monadic_single
[opc_mask_shift
](roundData
, rFm
);