2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
6 #include "mathffp_intern.h"
8 /*****************************************************************************
12 AROS_LH2(float, SPMul
,
15 AROS_LHA(float, fnum1
, D1
),
16 AROS_LHA(float, fnum2
, D0
),
19 struct LibHeader
*, MathBase
, 13, Mathffp
)
22 Multiply two ffp numbers
32 negative : result is negative
33 overflow : result is out of range
39 *****************************************************************************/
43 char Exponent
= ((char) fnum1
& FFPExponent_Mask
)
44 + ((char) fnum2
& FFPExponent_Mask
) - 0x41;
45 ULONG Mant1H
= ( (ULONG
) (fnum1
& FFPMantisse_Mask
)) >> 20;
46 ULONG Mant2H
= ( (ULONG
) (fnum2
& FFPMantisse_Mask
)) >> 20;
47 ULONG Mant1L
= (((ULONG
) (fnum1
& FFPMantisse_Mask
)) >> 8) & 0x00000fff;
48 ULONG Mant2L
= (((ULONG
) (fnum2
& FFPMantisse_Mask
)) >> 8) & 0x00000fff;
51 Res
= (Mant1H
* Mant2H
) << 8;
52 Res
+= ((Mant1H
* Mant2L
) >> 4);
53 Res
+= ((Mant1L
* Mant2H
) >> 4);
54 Res
+= ((Mant1L
* Mant2L
) >> 16);
55 Res
&= FFPMantisse_Mask
;
57 /* Bit 32 is not set */
60 Res
<<= 1; /* rotate the mantisse by one bit to the left */
69 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
73 Res
|= ((fnum1
& FFPSign_Mask
) ^ (fnum2
& FFPSign_Mask
) );
76 if ((char) Exponent
< 0 || (char) Exponent
== 0x7f)
78 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
79 D(kprintf("SPMul(%x * %x) = %x\n",fnum1
,fnum2
,Res
));
80 return (Res
| (FFPMantisse_Mask
+ FFPExponent_Mask
));
87 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
90 D(kprintf("SPMul(%x * %x) = %x\n", fnum1
, fnum2
, Res
));