2 ** libgcc support for software floating point.
\r
3 ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
\r
4 ** Permission is granted to do *anything* you want with this file,
\r
5 ** commercial or otherwise, provided this message remains intact. So there!
\r
6 ** I would appreciate receiving any updates/patches/changes that anyone
\r
7 ** makes, and am willing to be the repository for said changes (am I
\r
8 ** making a big mistake?).
\r
11 ** Pipeline Associates, Inc.
\r
12 ** pipeline!phw@motown.com or
\r
13 ** sun!pipeline!phw or
\r
14 ** uunet!motown!pipeline!phw
\r
18 ** $Id: fsdiv.c 3513 2004-10-01 14:49:51Z vrokas $
\r
21 /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
\r
31 /* divide two floats */
\r
32 float __fsdiv (float a1, float a2) _FS_REENTRANT
\r
34 FS_STATIC volatile union float_long fl1, fl2;
\r
44 /* subtract exponents */
\r
50 sign = SIGN (fl1.l) ^ SIGN (fl2.l);
\r
52 /* divide by zero??? */
\r
54 {/* return NaN or -NaN */
\r
59 /* numerator zero??? */
\r
63 /* now get mantissas */
\r
64 mant1 = MANT (fl1.l);
\r
65 mant2 = MANT (fl2.l);
\r
67 /* this assures we have 25 bits of precision in the end */
\r
74 /* now we perform repeated subtraction of fl2.l from fl1.l */
\r
91 /* normalize down */
\r
97 /* pack up and go home */
\r
99 fl1.l = (sign ? SIGNBIT : 0) | 0x7F800000;
\r
103 fl1.l = PACK (sign ? SIGNBIT : 0 , exp, result);
\r