2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
6 #include "mathffp_intern.h"
10 Multiply two ffp numbers
18 negative : result is negative
19 overflow : result is out of range
34 AROS_LH2(float, SPMul
,
35 AROS_LHA(float, fnum1
, D1
),
36 AROS_LHA(float, fnum2
, D0
),
37 struct LibHeader
*, MathBase
, 13, Mathffp
42 char Exponent
= ((char) fnum1
& FFPExponent_Mask
)
43 + ((char) fnum2
& FFPExponent_Mask
) - 0x41;
44 ULONG Mant1H
= ( (ULONG
) (fnum1
& FFPMantisse_Mask
)) >> 20;
45 ULONG Mant2H
= ( (ULONG
) (fnum2
& FFPMantisse_Mask
)) >> 20;
46 ULONG Mant1L
= (((ULONG
) (fnum1
& FFPMantisse_Mask
)) >> 8) & 0x00000fff;
47 ULONG Mant2L
= (((ULONG
) (fnum2
& FFPMantisse_Mask
)) >> 8) & 0x00000fff;
50 Res
= (Mant1H
* Mant2H
) << 8;
51 Res
+= ((Mant1H
* Mant2L
) >> 4);
52 Res
+= ((Mant1L
* Mant2H
) >> 4);
53 Res
+= ((Mant1L
* Mant2L
) >> 16);
55 /* Bit 32 is not set */
58 Res
<<= 1; /* rotate the mantisse by one bit to the left */
67 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
71 Res
|= ((fnum1
& FFPSign_Mask
) ^ (fnum2
& FFPSign_Mask
) );
74 if ((char) Exponent
< 0 || (char) Exponent
== 0x7f)
76 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
77 kprintf("%x * %x = %x\n",fnum1
,fnum2
,Res
);
78 return (Res
| (FFPMantisse_Mask
+ FFPExponent_Mask
));
85 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
88 kprintf("%x * %x = %x\n",fnum1
,fnum2
,Res
);