2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
6 #include "mathieeesingbas_intern.h"
10 Multiply two IEEE single precision numbers
17 negative : result is negative
18 overflow : result is out of range
33 AROS_LH2(float, IEEESPMul
,
34 AROS_LHA(float, y
, D0
),
35 AROS_LHA(float, z
, D1
),
36 struct LibHeader
*, MathIeeeSingBasBase
, 13, Mathieeesingbas
41 ULONG Mant1H
= ((y
& 0x00fff000) >> 12 ) | 0x00000800;
42 ULONG Mant2H
= ((z
& 0x00fff000) >> 12 ) | 0x00000800;
43 ULONG Mant1L
= y
& 0x00000fff;
44 ULONG Mant2L
= z
& 0x00000fff;
46 LONG Exponent
= ((( y
& IEEESPExponent_Mask
))
47 + (( z
& IEEESPExponent_Mask
)) - 0x3f800000 );
51 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
52 return ((y
& IEEESPSign_Mask
) ^ (z
& IEEESPSign_Mask
) );
55 Res
= (Mant1H
* Mant2H
) << 8;
56 Res
+= ((Mant1H
* Mant2L
) >> 4);
57 Res
+= ((Mant1L
* Mant2H
) >> 4);
58 Res
+= ((Mant1L
* Mant2L
) >> 16);
60 /* Bit 32 is not set */
61 if ((LONG
)Res
> 0) Res
+= Res
;
62 else Exponent
+= 0x00800000;
64 /* Correction for precision */
65 if ((char) Res
< 0) Res
+= 0x100;
68 Res
&= IEEESPMantisse_Mask
;
70 Res
|= ((y
& IEEESPSign_Mask
) ^ (z
& IEEESPSign_Mask
) );
74 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
75 return (0x7f800000 | (Res
& IEEESPSign_Mask
) );
80 if ( Res
< 0) SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);