Added mcs51 assembly versions for the 12 float/integer conversion functions.
authorpjs <pjs@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 27 Dec 2004 10:51:44 +0000 (10:51 +0000)
committerpjs <pjs@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 27 Dec 2004 10:51:44 +0000 (10:51 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3615 4a8a32a2-be11-0410-ad9d-d568d2c75423

20 files changed:
ChangeLog
device/include/float.h
device/lib/_fs2schar.c
device/lib/_fs2sint.c
device/lib/_fs2slong.c
device/lib/_fs2uchar.c
device/lib/_fs2uint.c
device/lib/_fs2ulong.c
device/lib/_fsget1arg.c
device/lib/_fsget2args.c
device/lib/_fsnormalize.c
device/lib/_fsreturnval.c
device/lib/_fsrshift.c
device/lib/_fsswapargs.c
device/lib/_schar2fs.c
device/lib/_sint2fs.c
device/lib/_slong2fs.c
device/lib/_uchar2fs.c
device/lib/_uint2fs.c
device/lib/_ulong2fs.c

index 568e529faeabb7dd7a5df19c5df0654f6310aa14..ac10df987be19c39639ef1cb754e1698b7bd2fc0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,21 @@
-2004-12-25 Paul Stoffregen <paul AT pjrc.com>
+2004-12-27 Paul Stoffregen <paul AT pjrc.com>
+
+       * device/lib/_fs2slong.c: added mcs51 assembly version
+       * device/lib/_fs2sint.c: added mcs51 assembly version
+       * device/lib/_fs2schar.c: added mcs51 assembly version
+       * device/lib/_fs2ulong.c: added mcs51 assembly version
+       * device/lib/_fs2uint.c: added mcs51 assembly version
+       * device/lib/_fs2uchar.c: added mcs51 assembly version
+       * device/lib/_slong2fs.c: added mcs51 assembly version
+       * device/lib/_sint2fs.c: added mcs51 assembly version
+       * device/lib/_schar2fs.c: added mcs51 assembly version
+       * device/lib/_ulong2fs.c: added mcs51 assembly version
+       * device/lib/_uint2fs.c: added mcs51 assembly version
+       * device/lib/_uchar2fs.c: added mcs51 assembly version
+       * device/include/float.h: added #define to select asm vs c
+
+2004-12-26 Paul Stoffregen <paul AT pjrc.com>
+
        * device/lib/printf_fast.c: improvements to float output
        * device/include/float.h: add defines for assembly float library
        * device/lib/_fsget1arg.c: receive 1 float arg
index 1c8292b4e340eda2232b246527d4b2012212f177..3eea235afb2b35263c8f613c78c8b0c9b652ddfd 100644 (file)
@@ -73,6 +73,8 @@ char __fsqt (float, float);
 
 #if defined(SDCC_FLOAT_LIB) && defined(SDCC_mcs51) && !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
 
+#define FLOAT_ASM_MCS51
+
 // This adds extra code for proper round-off, in
 // an attempt to match the results from gcc.
 #define FLOAT_FULL_ACCURACY
index 8ccf1ebd4db58848b5976677a8c6e81e0cb3ddb1..0bf02fe0c8f5794ec2573eccf509210fe19897a5 100644 (file)
@@ -1,5 +1,71 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+
+#ifdef FLOAT_ASM_MCS51
+
+// char __fs2schar (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___fs2schar
+___fs2schar:
+       lcall   ___fs2slong
+       jnb     sign_a, fs2schar_pos
+fs2schar_neg:
+       cpl     a
+       jnz     fs2schar_maxval_neg
+       mov     a, b
+       cpl     a
+       jnz     fs2schar_maxval_neg
+       mov     a, dph
+       cpl     a
+       jnz     fs2schar_maxval_neg
+       mov     a, dpl
+       jnb     acc.7, fs2schar_maxval_neg
+       ret
+fs2schar_maxval_neg:
+       mov     dpl, #0x80
+       ret
+fs2schar_pos:
+       jnz     fs2schar_maxval_pos
+       mov     a, b
+       jnz     fs2schar_maxval_pos
+       mov     a, dph
+       jnz     fs2schar_maxval_pos
+       mov     a, dpl
+       jb      acc.7, fs2schar_maxval_pos
+       ret
+fs2schar_maxval_pos:
+       mov     dpl, #0x7F
+       ret
+       _endasm;
+}
+
+
+#else
+
+
 /* convert float to signed char */
 signed char __fs2schar (float f) {
   signed long sl=__fs2slong(f);
@@ -9,3 +75,6 @@ signed char __fs2schar (float f) {
     return -CHAR_MIN;
   return sl;
 }
+
+#endif
+
index 78c179838f39071ce3e6eab383400e39e925c744..4a748dad74430c74d4cf00aa61e2ce36e2e89b2c 100644 (file)
@@ -1,5 +1,66 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+// int __fs2sint (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___fs2sint
+___fs2sint:
+       lcall   ___fs2slong
+       jnb     sign_a, fs2sint_pos
+fs2sint_neg:
+       cpl     a
+       jnz     fs2sint_maxval_neg
+       mov     a, b
+       cpl     a
+       jnz     fs2sint_maxval_neg
+       mov     a, dph
+       jnb     acc.7, fs2sint_maxval_neg
+       ret
+fs2sint_maxval_neg:
+       mov     dptr, #0x8000
+       ret
+fs2sint_pos:
+       jnz     fs2sint_maxval_pos
+       mov     a, b
+       jnz     fs2sint_maxval_pos
+       mov     a, dph
+       jb      acc.7, fs2sint_maxval_pos
+       ret
+fs2sint_maxval_pos:
+       mov     dptr, #0x7FFF
+       ret
+       _endasm;
+}
+
+
+#else
+
+
+
 /* convert float to signed int */
 signed int __fs2sint (float f) {
   signed long sl=__fs2slong(f);
@@ -9,3 +70,6 @@ signed int __fs2sint (float f) {
     return -INT_MIN;
   return sl;
 }
+
+#endif
+
index 236ef878789d91600cf3be43e5d70236c4d3680e..65d3d9acb2ce1afe615a488ae7b17a87a86d77c2 100644 (file)
@@ -1,5 +1,90 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+// long __fs2slong (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___fs2slong
+___fs2slong:
+       lcall   fsgetarg
+       clr     c
+       mov     a, #158
+       subb    a, exp_a
+       jc      fs2slong_maxval         //  |x| >= 2^32
+fs2slong_int_ok:
+       mov     r1, #0
+       lcall   fs_rshift_a
+       jnb     sign_a, fs2slong_pos
+fs2slong_neg:
+       mov     a, r1
+       cpl     a
+       add     a, #1
+       mov     dpl, a
+       mov     a, r2
+       cpl     a
+       addc    a, #0
+       mov     dph, a
+       mov     a, r3
+       cpl     a
+       addc    a, #0
+       mov     b, a
+       mov     a, r4
+       cpl     a
+       addc    a, #0
+       jnb     acc.7, fs2slong_maxval_neg  // x < -0x80000000
+       ret
+fs2slong_pos:
+       mov     a, r4
+       jb      acc.7, fs2slong_maxval_pos  //  x > 0x7FFFFFFF
+       mov     dpl, r1
+       mov     dph, r2
+       mov     b, r3
+       ret
+fs2slong_maxval:
+       jnb     sign_a, fs2slong_maxval_pos
+fs2slong_maxval_neg:
+       clr     a
+       mov     dpl, a
+       mov     dph, a
+       mov     b, a
+       mov     a, #0x80
+       ret
+fs2slong_maxval_pos:
+       mov     a, #0xFF
+       mov     dpl, a
+       mov     dph, a
+       mov     b, a
+       mov     a, #0x7F
+       ret
+       _endasm;
+}
+
+#else
+
+
 /* convert float to signed long */
 signed long __fs2slong (float f) {
 
@@ -12,3 +97,5 @@ signed long __fs2slong (float f) {
     return __fs2ulong(f);
   }
 }
+
+#endif
index ce4a927203ea58cd805b023b4a76ddf822224c10..2b021fd04cb22f848c5c6df387fc67dc3f328b3e 100644 (file)
@@ -1,5 +1,45 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+// unsigned char __fs2uchar (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___fs2uchar
+___fs2uchar:
+       mov     r7, #134
+       lcall   fs2ulong_begin
+       mov     dpl, a
+       ret
+       _endasm;
+}
+
+#else
+
+
+
+
 /* convert float to unsigned char */
 unsigned char __fs2uchar (float f) {
   unsigned long ul=__fs2ulong(f);
@@ -7,3 +47,5 @@ unsigned char __fs2uchar (float f) {
   return ul;
 }
 
+#endif
+
index 186b7f37a9e7f21797b61e75c5cac4717d1206b2..0ed5db6469448c119bc1f75c26852efcfb4ff39b 100644 (file)
@@ -1,5 +1,44 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+// unsigned int __fs2uint (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___fs2uint
+___fs2uint:
+       mov     r7, #142
+       lcall   fs2ulong_begin
+       mov     dph, a
+       mov     dpl, b
+       ret
+       _endasm;
+}
+
+#else
+
+
 unsigned long __fs2ulong (float a1);
 
 /* convert float to unsigned int */
@@ -9,3 +48,5 @@ unsigned int __fs2uint (float f) {
   return ul;
 }
 
+#endif
+
index 0b7461435b163c45e7afaba146c0d8f0ee4cd2bc..4a2da50d63e13cce76c6431c5125ae6670e5b430 100644 (file)
@@ -1,3 +1,72 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
+#include <float.h>
+
+
+#ifdef FLOAT_ASM_MCS51
+
+// unsigned long __fs2ulong (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___fs2ulong
+___fs2ulong:
+       mov     r7, #158
+       .globl  fs2ulong_begin
+fs2ulong_begin:
+       lcall   fsgetarg
+       jnb     sign_a, fs2ulong_int
+       ljmp    fs_return_zero
+
+fs2ulong_int:
+       clr     c
+       mov     a, r7
+       subb    a, exp_a
+       jnc     fs2ulong_int_ok
+       // if we get here, x >= 2^32
+       mov     a, #0xFF
+       mov     b, a
+       mov     dph, a
+       mov     dpl, a
+       ret
+
+fs2ulong_int_ok:
+       mov     r1, #0
+       lcall   fs_rshift_a
+
+fs2ulong_done:
+       mov     dpl, r1
+       mov     dph, r2
+       mov     b, r3
+       mov     a, r4
+       ret
+       _endasm;
+}
+
+
+#else
+
+
+
+
 /*
 ** libgcc support for software floating point.
 ** Copyright (C) 1991 by Pipeline Associates, Inc.  All rights reserved.
@@ -16,7 +85,6 @@
 
 /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
 
-#include <float.h>
 
 union float_long
 {
@@ -45,6 +113,6 @@ __fs2ulong (float a1)
   return l;
 }
 
-
+#endif
 
 
index bee256b9ed3c76a0a472e71fdd4e69b9102c6d30..abf17260ef0cca4a97555ad83d87be9fbc33ac19 100644 (file)
@@ -1,3 +1,22 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
 #define SDCC_FLOAT_LIB
 #include <float.h>
 
index 3a9e9fe42fcc54cca4d610fd9a470d251cd75f60..404b8ad11f4c4899579ef61394b462a3d7879074 100644 (file)
@@ -1,3 +1,23 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+
 #define SDCC_FLOAT_LIB
 #include <float.h>
 
@@ -56,76 +76,3 @@ fsgetargs:
 
 
 
-#if 0
-// This old version was designed before the change to make all this
-// code fully reentrant.  What a mess the 2nd parameter turns out to
-// be.
-
-void __fsgetargs (float a, float b)
-{
-       a;      // passed in a,b,dph,dpl
-       b;      // ___fsadd_PARM_2
-
-       _asm
-       // extract the two inputs, placing them into:
-       //      sign     exponent   mantiassa
-       //      ----     --------   ---------
-       //  a:  sign_a   exp_a     r4/r3/r2
-       //  b:  sign_b   exp_b     r7/r6/r5
-       //
-       mov     r2, dpl
-       mov     r3, dph
-       mov     c, b.7
-       rlc     a
-       mov     sign_a, c
-       jz      00001$
-       setb    b.7
-00001$:
-       mov     exp_a, a
-       mov     r4, b
-#ifdef SDCC_MODEL_SMALL
-       mov     r5, (___fsadd_PARM_2 + 0)
-       mov     r6, (___fsadd_PARM_2 + 1)
-       mov     b, (___fsadd_PARM_2 + 2)
-       mov     a, (___fsadd_PARM_2 + 3)
-       mov     c, b.7
-       rlc     a
-       mov     sign_b, c
-       jz      00002$
-       setb    b.7
-00002$:
-       mov     exp_b, a
-       mov     r7, b
-#endif
-       _endasm;
-}
-
-
-#ifdef SDCC_MODEL_LARGE
-void __fsgetarglarge2 (void)
-{
-       _asm
-       movx    a, @dptr
-       mov     r5, a
-       inc     dptr
-       movx    a, @dptr
-       mov     r6, a
-       inc     dptr
-       movx    a, @dptr
-       mov     b, a
-       inc     dptr
-       movx    a, @dptr
-       mov     c, b.7
-       rlc     a
-       mov     sign_b, c
-       jz      00002$
-       setb    b.7
-00002$:
-       mov     exp_b, a
-       mov     r7, b
-       _endasm;
-}
-#endif
-
-#endif
-
index f985b8bbbf7abc33cfb184144ea58fd3ad70991c..f404452cc8bfb82898c1eeab1d7b3180b784ac94 100644 (file)
@@ -1,3 +1,23 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+
 #define SDCC_FLOAT_LIB
 #include <float.h>
 
index 95f01e11d790d5d0a22f10d552ba9b4a57195a6b..798f934b7765aaf96181b5ae9a6200afbe30ac7d 100644 (file)
@@ -1,3 +1,23 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+
 #define SDCC_FLOAT_LIB
 #include <float.h>
 
index 4928fa5f49884f971ebdf7b01fc28e08718b370c..5e7e7e90ae5870ab032262fc917a715250aed73c 100644 (file)
@@ -1,3 +1,23 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+
 #define SDCC_FLOAT_LIB
 #include <float.h>
 
index aba533b447a35ac6d4ee0b15bb4f3ec80c6c8afd..85404cb4368601360cd8ffbd62be34bfd5f5c8fa 100644 (file)
@@ -1,3 +1,23 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+
 #define SDCC_FLOAT_LIB
 #include <float.h>
 
index 2a8fb4388bb176bfdf8fd706b9592dc7485c9e7b..73066d1b6dbad2ca7a97671bf1bc70dcac95c795 100644 (file)
@@ -1,6 +1,51 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+// float __schar2fs (char c)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___schar2fs
+___schar2fs:
+       mov     r4, dpl
+       clr     a
+       mov     r3, a
+       mov     r2, a
+       mov     r1, a
+       mov     a, #134
+       ljmp    slong2fs_doit
+       _endasm;
+}
+
+#else
+
+
 /* convert signed char to float */
 float __schar2fs (signed char sc) {
   return __slong2fs(sc);
 }
+
+#endif
+
index 0c86277cd12eac38b817cfb1ce41d103c64e46dd..eacde5d5efa632cd3ac5cfcaadd566854e029b83 100644 (file)
@@ -1,6 +1,50 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+// float long __sint2fs (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___sint2fs
+___sint2fs:
+       mov     r4, dph
+       mov     r3, dpl
+       mov     r2, #0
+       mov     r1, #0
+       mov     a, #142
+       ljmp    slong2fs_doit
+       _endasm;
+}
+
+#else
+
+
 /* convert signed int to float */
 float __sint2fs (signed int si) {
   return __slong2fs(si);
 }
+
+#endif
+
index 394fba874f8dbbb3fdad4856acc1bfc55db91372..da1938d08b3c7aa8ccabe960df7096c62896b802 100644 (file)
@@ -1,5 +1,71 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+//float __slong2fs (long x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___slong2fs
+___slong2fs:
+       mov     r4, a
+       mov     r3, b
+       mov     r2, dph
+       mov     r1, dpl
+       mov     a, #158
+       .globl  slong2fs_doit
+slong2fs_doit:
+       mov     exp_a, a
+       clr     sign_a
+       mov     a, r4
+       jnb     acc.7, slong2fs_positive
+       setb    sign_a
+       mov     a, r1
+       cpl     a
+       add     a, #1
+       mov     r1, a
+       mov     a, r2
+       cpl     a
+       addc    a, #0
+       mov     r2, a
+       mov     a, r3
+       cpl     a
+       addc    a, #0
+       mov     r3, a
+       mov     a, r4
+       cpl     a
+       addc    a, #0
+       mov     r4, a
+slong2fs_positive:
+       lcall   fs_normalize_a
+       ljmp    fs_round_and_return
+       _endasm;
+}
+
+#else
+
+
 /* convert signed long to float */
 float __slong2fs (signed long sl) {
   if (sl<0) 
@@ -7,3 +73,6 @@ float __slong2fs (signed long sl) {
   else 
     return __ulong2fs(sl);
 }
+
+#endif
+
index 3e9198820efbe08e82d57d25169101acae23ab91..31af32d8fef8a54d161b07d779c73d99ebd6a4ad 100644 (file)
@@ -1,6 +1,51 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+// float long __uchar2fs (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___uchar2fs
+___uchar2fs:
+       clr     a
+       mov     r4, dpl
+       mov     r3, a
+       mov     r2, a
+       mov     r1, a
+       mov     a, #134
+       ljmp    ulong2fs_doit
+       _endasm;
+}
+
+#else
+
+
+
 /* convert unsigned char to float */
 float __uchar2fs (unsigned char uc) {
   return __ulong2fs(uc);
 }
+
+#endif
index 9b443fa9c70107f83adf5a1b3ffe92eb3f4cf2c7..bf752b02245eeded3583c5bcd7f4764461cbdd07 100644 (file)
@@ -1,6 +1,51 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#define SDCC_FLOAT_LIB
 #include <float.h>
 
+
+#ifdef FLOAT_ASM_MCS51
+
+// float long __uint2fs (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___uint2fs
+___uint2fs:
+       clr     a
+       mov     r4, dph
+       mov     r3, dpl
+       mov     r2, a
+       mov     r1, a
+       mov     a, #142
+       ljmp    ulong2fs_doit
+       _endasm;
+}
+
+#else
+
+
+
 /* convert unsigned int to float */
 float __uint2fs (unsigned int ui) {
   return __ulong2fs(ui);
 }
+
+#endif
+
index f379420494a11e4c1a49823ef5e8ab80ea28c884..1a4d6b58209adefd97ffe45cbc07eaa29d1ce431 100644 (file)
@@ -1,3 +1,53 @@
+/* Floating point library in optimized assembly for 8051
+ * Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+ *
+ * This program 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
+ * of the License, 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 program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+
+#define SDCC_FLOAT_LIB
+#include <float.h>
+
+
+#ifdef FLOAT_ASM_MCS51
+
+// float long __ulong2fs (float x)
+static void dummy(void) _naked
+{
+       _asm
+       .globl  ___ulong2fs
+___ulong2fs:
+       mov     r4, a
+       mov     r3, b
+       mov     r2, dph
+       mov     r1, dpl
+       mov     a, #158
+       .globl  ulong2fs_doit
+ulong2fs_doit:
+       clr     sign_a
+long2fs_doit:
+       mov     exp_a, a
+       lcall   fs_normalize_a
+       ljmp    fs_round_and_return
+       _endasm;
+}
+
+#else
+
+
+
 /*
 ** libgcc support for software floating point.
 ** Copyright (C) 1991 by Pipeline Associates, Inc.  All rights reserved.
@@ -16,8 +66,6 @@
 
 /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
 
-#include <float.h>
-
 union float_long
   {
     float f;
@@ -60,3 +108,6 @@ float __ulong2fs (unsigned long a )
 
   return (fl.f);
 }
+
+#endif
+