2 ** libgcc support for software floating point.
3 ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
4 ** Permission is granted to do *anything* you want with this file,
5 ** commercial or otherwise, provided this message remains intact. So there!
6 ** I would appreciate receiving any updates/patches/changes that anyone
7 ** makes, and am willing to be the repository for said changes (am I
8 ** making a big mistake?).
11 ** Pipeline Associates, Inc.
12 ** pipeline!phw@motown.com or
13 ** sun!pipeline!phw or
14 ** uunet!motown!pipeline!phw
18 ** $Id: fsmul.c 4776 2007-04-29 13:15:51Z borutr $
21 /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
31 /* multiply two floats */
32 float __fsmul (float a1, float a2) _FS_REENTRANT
34 FS_STATIC volatile union float_long fl1, fl2;
45 /* compute sign and exponent */
46 sign = SIGN (fl1.l) ^ SIGN (fl2.l);
47 exp = EXP (fl1.l) - EXCESS;
53 /* the multiply is done as one 16x16 multiply and two 16x8 multiples */
54 result = (fl1.l >> 8) * (fl2.l >> 8);
55 result += ((fl1.l & (unsigned long) 0xFF) * (fl2.l >> 8)) >> 8;
56 result += ((fl2.l & (unsigned long) 0xFF) * (fl1.l >> 8)) >> 8;
58 if (0 != (result & SIGNBIT))
74 /* pack up and go home */
76 fl1.l = (sign ? SIGNBIT : 0) | 0x7F800000;
80 fl1.l = PACK (sign ? SIGNBIT : 0 , exp, result);