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 /* divide two floats */
28 float __fsdiv (float a1, float a2)
30 volatile union float_long fl1, fl2;
32 volatile unsigned long mask;
33 volatile long mant1, mant2;
40 /* subtract exponents */
46 sign = SIGN (fl1.l) ^ SIGN (fl2.l);
48 /* divide by zero??? */
50 /* return NaN or -NaN */
53 /* numerator zero??? */
57 /* now get mantissas */
61 /* this assures we have 25 bits of precision in the end */
68 /* now we perform repeated subtraction of fl2.l from fl1.l */
91 /* pack up and go home */
92 fl1.l = PACK (sign ? 1ul<<31 : 0, (unsigned long) exp, result);