]> git.gag.com Git - fw/sdcc/commitdiff
* sources in device/lib/pic16/libsdcc/float/*.c were empty,
authorvrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 9 Jul 2004 23:28:16 +0000 (23:28 +0000)
committervrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 9 Jul 2004 23:28:16 +0000 (23:28 +0000)
contents updated

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3377 4a8a32a2-be11-0410-ad9d-d568d2c75423

20 files changed:
device/lib/pic16/libsdcc/float/fs2schar.c
device/lib/pic16/libsdcc/float/fs2sint.c
device/lib/pic16/libsdcc/float/fs2slong.c
device/lib/pic16/libsdcc/float/fs2uchar.c
device/lib/pic16/libsdcc/float/fs2uint.c
device/lib/pic16/libsdcc/float/fs2ulong.c
device/lib/pic16/libsdcc/float/fsadd.c
device/lib/pic16/libsdcc/float/fsdiv.c
device/lib/pic16/libsdcc/float/fseq.c
device/lib/pic16/libsdcc/float/fsgt.c
device/lib/pic16/libsdcc/float/fslt.c
device/lib/pic16/libsdcc/float/fsmul.c
device/lib/pic16/libsdcc/float/fsneq.c
device/lib/pic16/libsdcc/float/fssub.c
device/lib/pic16/libsdcc/float/schar2fs.c
device/lib/pic16/libsdcc/float/sint2fs.c
device/lib/pic16/libsdcc/float/slong2fs.c
device/lib/pic16/libsdcc/float/uchar2fs.c
device/lib/pic16/libsdcc/float/uint2fs.c
device/lib/pic16/libsdcc/float/ulong2fs.c

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..17e5ea0d8bd7b6f7da234c2fdd781613272c56d8 100644 (file)
@@ -0,0 +1,45 @@
+/*-------------------------------------------------------------------------
+   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;
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..bcf7703076a98a58b741a6bfb92f39cceef03720 100644 (file)
@@ -0,0 +1,46 @@
+/*-------------------------------------------------------------------------
+   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;
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..dc57c2d7c0621c2cf103cecefd0ec167bdc20305 100644 (file)
@@ -0,0 +1,47 @@
+/*-------------------------------------------------------------------------
+   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);
+  }
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3d422e1d03a38b75fd7be8235328b8b3e1674965 100644 (file)
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+   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;
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ac4742d11b8cb62d79de4a71a84d340bee6f18c9 100644 (file)
@@ -0,0 +1,44 @@
+/*-------------------------------------------------------------------------
+   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;
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8d290b18302a00d68bf4c46ceddbe045be9f4587 100644 (file)
@@ -0,0 +1,54 @@
+/*
+** 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;
+}
+
+
+
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3b07ce92d61bc0474ef3d2df845c0ea8471913d4 100644 (file)
@@ -0,0 +1,103 @@
+/*
+** 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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7126216a228a6b278da154c642465e90ed89033c 100644 (file)
@@ -0,0 +1,100 @@
+/*
+** 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);
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d8ba933301145cd4b34528557c2c747e383c24f8 100644 (file)
@@ -0,0 +1,44 @@
+/*
+** 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);
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..574898c271a4315699110b37291802705fb7d15c 100644 (file)
@@ -0,0 +1,49 @@
+/*
+** 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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..45eadf8aaadd816db7abb11078ce05714dd01cde 100644 (file)
@@ -0,0 +1,49 @@
+/*
+** 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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..315a04d618b85ecd3ae6cb213194ab6b0fb825c3 100644 (file)
@@ -0,0 +1,82 @@
+/*
+** 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);
+}
+
+
+
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2ed1b1ec38c7a8511c508a711b55705bdc5d60d1 100644 (file)
@@ -0,0 +1,51 @@
+/*
+** 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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..54770b591a11fe7ad52fa216d23b40c6a8d6b362 100644 (file)
@@ -0,0 +1,49 @@
+/*
+** 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; 
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d0028f68fe4291d816c77accc52793d1e9ae838b 100644 (file)
@@ -0,0 +1,39 @@
+/*-------------------------------------------------------------------------
+   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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4c3d65d745f36ae00f075129593d109bfddb776a 100644 (file)
@@ -0,0 +1,39 @@
+/*-------------------------------------------------------------------------
+   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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..11d38920dd0b420c33f552027e58349bebb9da93 100644 (file)
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+   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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..536cf674c985c6abc902ddc9fe0e866c47725f1a 100644 (file)
@@ -0,0 +1,39 @@
+/*-------------------------------------------------------------------------
+   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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2a846d7553df5fa8e9ec5ba8b2daace3369aab72 100644 (file)
@@ -0,0 +1,39 @@
+/*-------------------------------------------------------------------------
+   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);
+}
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..23123339a3a80f41db5be05724ae356e78d9e24b 100644 (file)
@@ -0,0 +1,76 @@
+/*
+** 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);
+}