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
17 /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
27 /* multiply two floats */
28 float __fsmul (float a1, float a2) {
29 volatile union float_long fl1, fl2;
30 volatile unsigned long result;
40 /* compute sign and exponent */
41 sign = SIGN (fl1.l) ^ SIGN (fl2.l);
42 exp = EXP (fl1.l) - EXCESS;
48 /* the multiply is done as one 16x16 multiply and two 16x8 multiples */
49 result = (fl1.l >> 8) * (fl2.l >> 8);
50 result += ((fl1.l & (unsigned long) 0xFF) * (fl2.l >> 8)) >> 8;
51 result += ((fl2.l & (unsigned long) 0xFF) * (fl1.l >> 8)) >> 8;
69 /* pack up and go home */
70 fl1.l = PACK (sign ? SIGNBIT : 0 , (unsigned long)exp, result);