summaryrefslogtreecommitdiff
path: root/device/lib/pic16/libsdcc/float
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /device/lib/pic16/libsdcc/float
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'device/lib/pic16/libsdcc/float')
-rw-r--r--device/lib/pic16/libsdcc/float/fs2schar.c42
-rw-r--r--device/lib/pic16/libsdcc/float/fs2sint.c42
-rw-r--r--device/lib/pic16/libsdcc/float/fs2slong.c46
-rw-r--r--device/lib/pic16/libsdcc/float/fs2uchar.c40
-rw-r--r--device/lib/pic16/libsdcc/float/fs2uint.c42
-rw-r--r--device/lib/pic16/libsdcc/float/fs2ulong.c73
-rw-r--r--device/lib/pic16/libsdcc/float/fsadd.c128
-rw-r--r--device/lib/pic16/libsdcc/float/fsdiv.c129
-rw-r--r--device/lib/pic16/libsdcc/float/fseq.c67
-rw-r--r--device/lib/pic16/libsdcc/float/fsgt.c73
-rw-r--r--device/lib/pic16/libsdcc/float/fslt.c73
-rw-r--r--device/lib/pic16/libsdcc/float/fsmul.c107
-rw-r--r--device/lib/pic16/libsdcc/float/fsneq.c74
-rw-r--r--device/lib/pic16/libsdcc/float/fssub.c72
-rw-r--r--device/lib/pic16/libsdcc/float/schar2fs.c36
-rw-r--r--device/lib/pic16/libsdcc/float/sint2fs.c36
-rw-r--r--device/lib/pic16/libsdcc/float/slong2fs.c39
-rw-r--r--device/lib/pic16/libsdcc/float/uchar2fs.c36
-rw-r--r--device/lib/pic16/libsdcc/float/uint2fs.c36
-rw-r--r--device/lib/pic16/libsdcc/float/ulong2fs.c103
20 files changed, 1294 insertions, 0 deletions
diff --git a/device/lib/pic16/libsdcc/float/fs2schar.c b/device/lib/pic16/libsdcc/float/fs2schar.c
new file mode 100644
index 0000000..16c4b04
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fs2schar.c
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+ fs2schar
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert float to signed char */
+signed char
+__fs2schar (float f) _FS_REENTRANT
+{
+ signed long sl = __fs2slong (f);
+
+ if (sl >= SCHAR_MAX)
+ return SCHAR_MAX;
+ if (sl <= SCHAR_MIN)
+ return -SCHAR_MIN;
+ return sl;
+}
diff --git a/device/lib/pic16/libsdcc/float/fs2sint.c b/device/lib/pic16/libsdcc/float/fs2sint.c
new file mode 100644
index 0000000..0f94c1a
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fs2sint.c
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+ fs2sint.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert float to signed int */
+signed int
+__fs2sint (float f) _FS_REENTRANT
+{
+ signed long sl = __fs2slong (f);
+
+ if (sl >= INT_MAX)
+ return INT_MAX;
+ if (sl <= INT_MIN)
+ return -INT_MIN;
+ return sl;
+}
diff --git a/device/lib/pic16/libsdcc/float/fs2slong.c b/device/lib/pic16/libsdcc/float/fs2slong.c
new file mode 100644
index 0000000..b252200
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fs2slong.c
@@ -0,0 +1,46 @@
+/*-------------------------------------------------------------------------
+ fs2slong.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert float to signed long */
+signed long
+__fs2slong (float f) _FS_REENTRANT
+{
+ if (!f)
+ return 0;
+
+ if (f < 0)
+ {
+ return -__fs2ulong (-f);
+ }
+ else
+ {
+ return __fs2ulong (f);
+ }
+}
diff --git a/device/lib/pic16/libsdcc/float/fs2uchar.c b/device/lib/pic16/libsdcc/float/fs2uchar.c
new file mode 100644
index 0000000..0cd54ef
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fs2uchar.c
@@ -0,0 +1,40 @@
+/*-------------------------------------------------------------------------
+ fs2uchar.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert float to unsigned char */
+unsigned char
+__fs2uchar (float f) _FS_REENTRANT
+{
+ unsigned long ul = __fs2ulong (f);
+
+ if (ul >= UCHAR_MAX)
+ return UCHAR_MAX;
+ return ul;
+}
diff --git a/device/lib/pic16/libsdcc/float/fs2uint.c b/device/lib/pic16/libsdcc/float/fs2uint.c
new file mode 100644
index 0000000..708386b
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fs2uint.c
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+ fs2uint.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+unsigned long __fs2ulong (float a1);
+
+/* convert float to unsigned int */
+unsigned int
+__fs2uint (float f) _FS_REENTRANT
+{
+ unsigned long ul = __fs2ulong(f);
+
+ if (ul >= UINT_MAX)
+ return UINT_MAX;
+ return ul;
+}
diff --git a/device/lib/pic16/libsdcc/float/fs2ulong.c b/device/lib/pic16/libsdcc/float/fs2ulong.c
new file mode 100644
index 0000000..a953849
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fs2ulong.c
@@ -0,0 +1,73 @@
+/*-------------------------------------------------------------------------
+ fs2ulong.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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) _FS_REENTRANT
+{
+ volatile union float_long fl1;
+ int exp;
+ unsigned 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;
+}
diff --git a/device/lib/pic16/libsdcc/float/fsadd.c b/device/lib/pic16/libsdcc/float/fsadd.c
new file mode 100644
index 0000000..b7f01e1
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fsadd.c
@@ -0,0 +1,128 @@
+/*-------------------------------------------------------------------------
+ fsadd.c.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+#include <float.h>
+
+union float_long
+ {
+ float f;
+ unsigned long l;
+ };
+
+/* add two floats */
+float
+__fsadd (float a1, float a2) _FS_REENTRANT
+{
+ volatile union float_long fl1, fl2;
+ long mant1, mant2;
+ int exp1, exp2;
+ 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;
+}
diff --git a/device/lib/pic16/libsdcc/float/fsdiv.c b/device/lib/pic16/libsdcc/float/fsdiv.c
new file mode 100644
index 0000000..fb353dd
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fsdiv.c
@@ -0,0 +1,129 @@
+/*-------------------------------------------------------------------------
+ fsdiv.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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) _FS_REENTRANT
+{
+ volatile union float_long fl1, fl2;
+ long result;
+ unsigned long mask;
+ long mant1, mant2;
+ 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 */
+ fl2.l = 0x7FC00000;
+ return fl2.f;
+ }
+
+ /* 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 */
+ if (exp >= 0x100)
+ fl1.l = (sign ? SIGNBIT : 0) | 0x7F800000;
+ else if (exp < 0)
+ fl1.l = 0;
+ else
+ fl1.l = PACK (sign ? SIGNBIT : 0 , exp, result);
+ return fl1.f;
+}
diff --git a/device/lib/pic16/libsdcc/float/fseq.c b/device/lib/pic16/libsdcc/float/fseq.c
new file mode 100644
index 0000000..9b645b8
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fseq.c
@@ -0,0 +1,67 @@
+/*-------------------------------------------------------------------------
+ fseq.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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) _FS_REENTRANT
+{
+ volatile union float_long fl1, fl2;
+
+ fl1.f = a1;
+ fl2.f = a2;
+
+ if (fl1.l == fl2.l)
+ return 1;
+ return 0;
+}
+
diff --git a/device/lib/pic16/libsdcc/float/fsgt.c b/device/lib/pic16/libsdcc/float/fsgt.c
new file mode 100644
index 0000000..93f4952
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fsgt.c
@@ -0,0 +1,73 @@
+/*-------------------------------------------------------------------------
+ fsgt.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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) _FS_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;
+}
diff --git a/device/lib/pic16/libsdcc/float/fslt.c b/device/lib/pic16/libsdcc/float/fslt.c
new file mode 100644
index 0000000..a246089
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fslt.c
@@ -0,0 +1,73 @@
+/*-------------------------------------------------------------------------
+ fslt.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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) _FS_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;
+}
diff --git a/device/lib/pic16/libsdcc/float/fsmul.c b/device/lib/pic16/libsdcc/float/fsmul.c
new file mode 100644
index 0000000..2a328c1
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fsmul.c
@@ -0,0 +1,107 @@
+/*-------------------------------------------------------------------------
+ fsmul.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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) _FS_REENTRANT
+{
+ volatile union float_long fl1, fl2;
+ unsigned long result;
+ 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;
+
+ /* round, phase 1 */
+ result += 0x40;
+
+ if (result & SIGNBIT)
+ {
+ /* round, phase 2 */
+ result += 0x40;
+ result >>= 8;
+ }
+ else
+ {
+ result >>= 7;
+ --exp;
+ }
+
+ result &= ~HIDDEN;
+
+ /* pack up and go home */
+ if (exp >= 0x100)
+ fl1.l = (sign ? SIGNBIT : 0) | 0x7F800000;
+ else if (exp < 0)
+ fl1.l = 0;
+ else
+ fl1.l = PACK (sign ? SIGNBIT : 0 , exp, result);
+ return fl1.f;
+}
diff --git a/device/lib/pic16/libsdcc/float/fsneq.c b/device/lib/pic16/libsdcc/float/fsneq.c
new file mode 100644
index 0000000..39bb6bb
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fsneq.c
@@ -0,0 +1,74 @@
+/*-------------------------------------------------------------------------
+ fsneq.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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) _FS_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;
+}
diff --git a/device/lib/pic16/libsdcc/float/fssub.c b/device/lib/pic16/libsdcc/float/fssub.c
new file mode 100644
index 0000000..da40447
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/fssub.c
@@ -0,0 +1,72 @@
+/*-------------------------------------------------------------------------
+ fssub.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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) _FS_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;
+}
diff --git a/device/lib/pic16/libsdcc/float/schar2fs.c b/device/lib/pic16/libsdcc/float/schar2fs.c
new file mode 100644
index 0000000..24b0f41
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/schar2fs.c
@@ -0,0 +1,36 @@
+/*-------------------------------------------------------------------------
+ schar2fs.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert signed char to float */
+float
+__schar2fs (signed char sc) _FS_REENTRANT
+{
+ return __slong2fs (sc);
+}
diff --git a/device/lib/pic16/libsdcc/float/sint2fs.c b/device/lib/pic16/libsdcc/float/sint2fs.c
new file mode 100644
index 0000000..22c601b
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/sint2fs.c
@@ -0,0 +1,36 @@
+/*-------------------------------------------------------------------------
+ sint2fs.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert signed int to float */
+float
+__sint2fs (signed int si) _FS_REENTRANT
+{
+ return __slong2fs (si);
+}
diff --git a/device/lib/pic16/libsdcc/float/slong2fs.c b/device/lib/pic16/libsdcc/float/slong2fs.c
new file mode 100644
index 0000000..7059e77
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/slong2fs.c
@@ -0,0 +1,39 @@
+/*-------------------------------------------------------------------------
+ slong2fs.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert signed long to float */
+float
+__slong2fs (signed long sl) _FS_REENTRANT
+{
+ if (sl < 0)
+ return -__ulong2fs (-sl);
+ else
+ return __ulong2fs (sl);
+}
diff --git a/device/lib/pic16/libsdcc/float/uchar2fs.c b/device/lib/pic16/libsdcc/float/uchar2fs.c
new file mode 100644
index 0000000..7af2e6c
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/uchar2fs.c
@@ -0,0 +1,36 @@
+/*-------------------------------------------------------------------------
+ uchar2fs.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert unsigned char to float */
+float
+__uchar2fs (unsigned char uc) _FS_REENTRANT
+{
+ return __ulong2fs (uc);
+}
diff --git a/device/lib/pic16/libsdcc/float/uint2fs.c b/device/lib/pic16/libsdcc/float/uint2fs.c
new file mode 100644
index 0000000..01f1535
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/uint2fs.c
@@ -0,0 +1,36 @@
+/*-------------------------------------------------------------------------
+ uint2fs.c
+
+ Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <float.h>
+
+/* convert unsigned int to float */
+float
+__uint2fs (unsigned int ui) _FS_REENTRANT
+{
+ return __ulong2fs (ui);
+}
diff --git a/device/lib/pic16/libsdcc/float/ulong2fs.c b/device/lib/pic16/libsdcc/float/ulong2fs.c
new file mode 100644
index 0000000..9c0d445
--- /dev/null
+++ b/device/lib/pic16/libsdcc/float/ulong2fs.c
@@ -0,0 +1,103 @@
+/*-------------------------------------------------------------------------
+ ulong2fs.c
+
+ Copyright (C) 1991, Pipeline Associates, Inc
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+/*
+** 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
+*/
+
+/* (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 ) _FS_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;
+}