+/*-------------------------------------------------------------------------
+ fs2schar.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+
+#include <float.h>
+
+/* convert float to signed char */
+signed char __fs2schar (float f)
+// reentrant
+{
+ signed long sl=__fs2slong(f);
+ if (sl>=CHAR_MAX)
+ return CHAR_MAX;
+ if (sl<=CHAR_MIN)
+ return -CHAR_MIN;
+ return sl;
+}
+/*-------------------------------------------------------------------------
+ fs2sint.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+
+/*
+** $Id$
+*/
+
+
+#include <float.h>
+
+/* convert float to signed int */
+signed int __fs2sint (float f)
+// reentrant
+{
+ signed long sl=__fs2slong(f);
+ if (sl>=INT_MAX)
+ return INT_MAX;
+ if (sl<=INT_MIN)
+ return -INT_MIN;
+ return sl;
+}
+/*-------------------------------------------------------------------------
+ fs2slong.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+/* convert float to signed long */
+signed long __fs2slong (float f)
+// reentrant
+{
+
+ if (!f)
+ return 0;
+
+ if (f<0) {
+ return -__fs2ulong(-f);
+ } else {
+ return __fs2ulong(f);
+ }
+}
+/*-------------------------------------------------------------------------
+ fs2uchar.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+/* convert float to unsigned char */
+unsigned char __fs2uchar (float f)
+// reentrant
+{
+ unsigned long ul=__fs2ulong(f);
+ if (ul>=UCHAR_MAX) return UCHAR_MAX;
+ return ul;
+}
+
+/*-------------------------------------------------------------------------
+ fs2uint.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+unsigned long __fs2ulong (float a1);
+
+/* convert float to unsigned int */
+unsigned int __fs2uint (float f)
+// reentrant
+{
+ unsigned long ul=__fs2ulong(f);
+ if (ul>=UINT_MAX) return UINT_MAX;
+ return ul;
+}
+
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+{
+ float f;
+ long l;
+};
+
+/* convert float to unsigned long */
+unsigned long __fs2ulong (float a1)
+// reentrant
+{
+ volatile union float_long fl1;
+ volatile int exp;
+ volatile long l;
+
+ fl1.f = a1;
+
+ if (!fl1.l || SIGN(fl1.l))
+ return (0);
+
+ exp = EXP (fl1.l) - EXCESS - 24;
+ l = MANT (fl1.l);
+
+ l >>= -exp;
+
+ return l;
+}
+
+
+
+
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ unsigned long l;
+ };
+
+/* add two floats */
+float __fsadd (float a1, float a2)
+// reentrant
+{
+ volatile long mant1, mant2;
+ volatile union float_long fl1, fl2;
+ volatile int exp1, exp2;
+ volatile unsigned long sign = 0;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+ /* check for zero args */
+ if (!fl1.l)
+ return (fl2.f);
+ if (!fl2.l)
+ return (fl1.f);
+
+ exp1 = EXP (fl1.l);
+ exp2 = EXP (fl2.l);
+
+ if (exp1 > exp2 + 25)
+ return (fl1.f);
+ if (exp2 > exp1 + 25)
+ return (fl2.f);
+
+ mant1 = MANT (fl1.l);
+ mant2 = MANT (fl2.l);
+
+ if (SIGN (fl1.l))
+ mant1 = -mant1;
+ if (SIGN (fl2.l))
+ mant2 = -mant2;
+
+ if (exp1 > exp2)
+ {
+ mant2 >>= exp1 - exp2;
+ }
+ else
+ {
+ mant1 >>= exp2 - exp1;
+ exp1 = exp2;
+ }
+ mant1 += mant2;
+
+ if (mant1 < 0)
+ {
+ mant1 = -mant1;
+ sign = SIGNBIT;
+ }
+ else if (!mant1)
+ return (0);
+
+ /* normalize */
+ while (mant1<HIDDEN) {
+ mant1 <<= 1;
+ exp1--;
+ }
+
+ /* round off */
+ while (mant1 & 0xff000000) {
+ if (mant1&1)
+ mant1 += 2;
+ mant1 >>= 1 ;
+ exp1++;
+ }
+
+ /* turn off hidden bit */
+ mant1 &= ~HIDDEN;
+
+ /* pack up and go home */
+ fl1.l = PACK (sign, (unsigned long) exp1, mant1);
+
+ return (fl1.f);
+}
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ long l;
+ };
+
+/* divide two floats */
+float __fsdiv (float a1, float a2)
+// reentrant
+{
+ volatile union float_long fl1, fl2;
+ volatile long result;
+ volatile unsigned long mask;
+ volatile long mant1, mant2;
+ volatile int exp ;
+ char sign;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+ /* subtract exponents */
+ exp = EXP (fl1.l) ;
+ exp -= EXP (fl2.l);
+ exp += EXCESS;
+
+ /* compute sign */
+ sign = SIGN (fl1.l) ^ SIGN (fl2.l);
+
+ /* divide by zero??? */
+ if (!fl2.l)
+ /* return NaN or -NaN */
+ return (-1.0);
+
+ /* numerator zero??? */
+ if (!fl1.l)
+ return (0);
+
+ /* now get mantissas */
+ mant1 = MANT (fl1.l);
+ mant2 = MANT (fl2.l);
+
+ /* this assures we have 25 bits of precision in the end */
+ if (mant1 < mant2)
+ {
+ mant1 <<= 1;
+ exp--;
+ }
+
+ /* now we perform repeated subtraction of fl2.l from fl1.l */
+ mask = 0x1000000;
+ result = 0;
+ while (mask)
+ {
+ if (mant1 >= mant2)
+ {
+ result |= mask;
+ mant1 -= mant2;
+ }
+ mant1 <<= 1;
+ mask >>= 1;
+ }
+
+ /* round */
+ result += 1;
+
+ /* normalize down */
+ exp++;
+ result >>= 1;
+
+ result &= ~HIDDEN;
+
+ /* pack up and go home */
+ fl1.l = PACK (sign ? 1ul<<31 : 0, (unsigned long) exp, result);
+ return (fl1.f);
+}
+
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ long l;
+ };
+
+/* compare two floats */
+char __fseq (float a1, float a2)
+// reentrant
+{
+ volatile union float_long fl1, fl2;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+ if (fl1.l == fl2.l)
+ return (1);
+ return (0);
+}
+
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ long l;
+ };
+
+/* compare two floats */
+char __fsgt (float a1, float a2)
+//reentrant
+{
+ volatile union float_long fl1, fl2;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+ if (fl1.l<0 && fl2.l<0) {
+ if (fl2.l > fl1.l)
+ return (1);
+ return (0);
+ }
+
+ if (fl1.l > fl2.l)
+ return (1);
+ return (0);
+}
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ long l;
+ };
+
+/* compare two floats */
+char __fslt (float a1, float a2)
+// reentrant
+{
+ volatile union float_long fl1, fl2;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+ if (fl1.l<0 && fl2.l<0) {
+ if (fl2.l < fl1.l)
+ return (1);
+ return (0);
+ }
+
+ if (fl1.l < fl2.l)
+ return (1);
+ return (0);
+}
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ unsigned long l;
+ };
+
+/* multiply two floats */
+float __fsmul (float a1, float a2)
+// reentrant
+{
+ volatile union float_long fl1, fl2;
+ volatile unsigned long result;
+ volatile int exp;
+ char sign;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+ if (!fl1.l || !fl2.l)
+ return (0);
+
+ /* compute sign and exponent */
+ sign = SIGN (fl1.l) ^ SIGN (fl2.l);
+ exp = EXP (fl1.l) - EXCESS;
+ exp += EXP (fl2.l);
+
+ fl1.l = MANT (fl1.l);
+ fl2.l = MANT (fl2.l);
+
+ /* the multiply is done as one 16x16 multiply and two 16x8 multiples */
+ result = (fl1.l >> 8) * (fl2.l >> 8);
+ result += ((fl1.l & (unsigned long) 0xFF) * (fl2.l >> 8)) >> 8;
+ result += ((fl2.l & (unsigned long) 0xFF) * (fl1.l >> 8)) >> 8;
+
+ if (result & SIGNBIT)
+ {
+ /* round */
+ result += 0x80;
+ result >>= 8;
+ }
+ else
+ {
+ /* round */
+ result += 0x40;
+ result >>= 7;
+ exp--;
+ }
+
+ result &= ~HIDDEN;
+
+ /* pack up and go home */
+ fl1.l = PACK (sign ? SIGNBIT : 0 , (unsigned long)exp, result);
+ return (fl1.f);
+}
+
+
+
+
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ long l;
+ };
+
+/* compare two floats */
+char __fsneq (float a1, float a2)
+// reentrant
+{
+ volatile union float_long fl1, fl2;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+#if 0
+ if (fl1.l<0 && fl2.l<0)
+ {
+ fl1.l ^= SIGNBIT;
+ fl2.l ^= SIGNBIT;
+ }
+#endif
+
+ if (fl1.l == fl2.l)
+ return (0);
+ return (1);
+}
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ long l;
+ };
+
+/* subtract two floats */
+float __fssub (float a1, float a2)
+// reentrant
+{
+ volatile union float_long fl1, fl2;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+ /* check for zero args */
+ if (!fl2.l)
+ return (fl1.f);
+ if (!fl1.l)
+ return (-fl2.f);
+
+ /* twiddle sign bit and add */
+ fl2.l ^= SIGNBIT;
+ return fl1.f + fl2.f;
+}
+/*-------------------------------------------------------------------------
+ schar2fs.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+/* convert signed char to float */
+float __schar2fs (signed char sc)
+// reentrant
+{
+ return __slong2fs(sc);
+}
+/*-------------------------------------------------------------------------
+ sint2fs.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+/* convert signed int to float */
+float __sint2fs (signed int si)
+// reentrant
+{
+ return __slong2fs(si);
+}
+/*-------------------------------------------------------------------------
+ slong2fs.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+/* convert signed long to float */
+float __slong2fs (signed long sl)
+//reentrant
+{
+ if (sl<0)
+ return -__ulong2fs(-sl);
+ else
+ return __ulong2fs(sl);
+}
+/*-------------------------------------------------------------------------
+ uchar2fs.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+/* convert unsigned char to float */
+float __uchar2fs (unsigned char uc)
+// reentrant
+{
+ return __ulong2fs(uc);
+}
+/*-------------------------------------------------------------------------
+ uint2fs.c :-
+
+ Adopted for float and pic16 port by
+ - Vangelis Rokas, vrokas@otenet.gr (2004)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+
+
+-------------------------------------------------------------------------*/
+
+/*
+** $Id$
+*/
+
+#include <float.h>
+
+/* convert unsigned int to float */
+float __uint2fs (unsigned int ui)
+//reentrant
+{
+ return __ulong2fs(ui);
+}
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/*
+** $Id$
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ long l;
+ };
+
+float __ulong2fs (unsigned long a )
+// reentrant
+{
+ int exp = 24 + EXCESS;
+ volatile union float_long fl;
+
+ if (!a)
+ {
+ return 0.0;
+ }
+
+ while (a & NORM)
+ {
+ // we lose accuracy here
+ a >>= 1;
+ exp++;
+ }
+
+
+ if(a < HIDDEN) {
+ do {
+ a<<=1;
+ exp--;
+ } while (a > HIDDEN);
+ }
+
+#if 0
+ while (a < HIDDEN) {
+ a <<= 1;
+ exp--;
+ }
+#endif
+
+#if 1
+ if ((a&0x7fffff)==0x7fffff) {
+ a=0;
+ exp++;
+ }
+#endif
+
+ a &= ~HIDDEN ;
+ /* pack up and go home */
+ fl.l = PACK(0,(unsigned long)exp, a);
+
+ return (fl.f);
+}