-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
#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
+/* 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);
return -CHAR_MIN;
return sl;
}
+
+#endif
+
+/* 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);
return -INT_MIN;
return sl;
}
+
+#endif
+
+/* 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) {
return __fs2ulong(f);
}
}
+
+#endif
+/* 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);
return ul;
}
+#endif
+
+/* 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 */
return ul;
}
+#endif
+
+/* 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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-#include <float.h>
union float_long
{
return l;
}
-
+#endif
+/* 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>
+/* 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>
-#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
-
+/* 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>
+/* 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>
+/* 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>
+/* 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>
+/* 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
+
+/* 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
+
+/* 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)
else
return __ulong2fs(sl);
}
+
+#endif
+
+/* 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
+/* 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
+
+/* 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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-#include <float.h>
-
union float_long
{
float f;
return (fl.f);
}
+
+#endif
+