* device/include/stdint.h: added
authormaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 17 Mar 2005 10:00:37 +0000 (10:00 +0000)
committermaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 17 Mar 2005 10:00:37 +0000 (10:00 +0000)
* device/lib/abs.c: added
* device/lib/labs.c: added
* device/include/stdlib.h: added abs() and labs() prototypes
* device/lib/libsdcc.lib: added abs and labs
* device/include/float.h,
* device/lib/_fsmul.c,
* device/lib/printf_fast.c,
* device/lib/printf_tiny.c: updated comments

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

ChangeLog
device/include/float.h
device/include/stdint.h [new file with mode: 0644]
device/include/stdlib.h
device/lib/_fsmul.c
device/lib/abs.c [new file with mode: 0644]
device/lib/labs.c [new file with mode: 0644]
device/lib/libsdcc.lib
device/lib/printf_fast.c
device/lib/printf_tiny.c

index 46309454293c9f8b456156601ee25cb5b1f6612b..bcc73684baa11cf9fbe9da6cfa50ec5b61a6ec74 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-03-17 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * device/include/stdint.h: added
+       * device/lib/abs.c: added
+       * device/lib/labs.c: added
+       * device/include/stdlib.h: added abs() and labs() prototypes
+       * device/lib/libsdcc.lib: added abs and labs
+       * device/include/float.h,
+       * device/lib/_fsmul.c,
+       * device/lib/printf_fast.c,
+       * device/lib/printf_tiny.c: updated comments
+
 2005-03-16 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
 
        * src/SDCCicode.c (geniCodeSwitch, geniCodeJumpTable): fixed
index 3eea235afb2b35263c8f613c78c8b0c9b652ddfd..3d3bb4c051f50ba046472ea1381709f4eab8a99c 100644 (file)
@@ -82,7 +82,7 @@ char __fsqt (float, float);
 // This adds about 66 bytes to the code size and
 // significantly speeds up shift operations more
 // than 8 bits (common when subtracting numbers
-// of siginifantly different magnitude and scaling
+// of significantly different magnitude and scaling
 // to fixed point)
 #define FLOAT_SHIFT_SPEEDUP
 
diff --git a/device/include/stdint.h b/device/include/stdint.h
new file mode 100644 (file)
index 0000000..12b26d5
--- /dev/null
@@ -0,0 +1,157 @@
+/*-------------------------------------------------------------------------
+  stdint.h - ISO C99 7.18 Integer types <stdint.h>
+
+             Written By -  Maarten Brock, sourceforge.brock@dse.nl (2005)
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+-------------------------------------------------------------------------*/
+
+#ifndef _STDINT_H
+#define _STDINT_H       1
+
+/* Exact integral types.  */
+
+/* Signed.  */
+
+typedef signed char             int8_t;
+typedef short int               int16_t;
+typedef long int                int32_t;
+
+/* Unsigned.  */
+typedef unsigned char           uint8_t;
+typedef unsigned short int      uint16_t;
+typedef unsigned long int       uint32_t;
+
+
+/* Small types.  */
+
+/* Signed.  */
+typedef signed char             int_least8_t;
+typedef short int               int_least16_t;
+typedef long int                int_least32_t;
+
+/* Unsigned.  */
+typedef unsigned char           uint_least8_t;
+typedef unsigned short int      uint_least16_t;
+typedef unsigned long int       uint_least32_t;
+
+
+/* Fast types.  */
+
+/* Signed.  */
+typedef signed char             int_fast8_t;
+typedef int                     int_fast16_t;
+typedef long int                int_fast32_t;
+
+/* Unsigned.  */
+typedef unsigned char           uint_fast8_t;
+typedef unsigned int            uint_fast16_t;
+typedef unsigned long int       uint_fast32_t;
+
+
+/* Types for `void *' pointers.  */
+typedef long int                intptr_t;
+typedef unsigned long int       uintptr_t;
+
+
+/* Largest integral types.  */
+typedef long int                intmax_t;
+typedef unsigned long int       uintmax_t;
+
+
+/* Limits of integral types.  */
+
+/* Minimum of signed integral types.  */
+# define INT8_MIN               (-128)
+# define INT16_MIN              (-32767-1)
+# define INT32_MIN              (-2147483647L-1)
+/* Maximum of signed integral types.  */
+# define INT8_MAX               (127)
+# define INT16_MAX              (32767)
+# define INT32_MAX              (2147483647L)
+
+/* Maximum of unsigned integral types.  */
+# define UINT8_MAX              (255)
+# define UINT16_MAX             (65535)
+# define UINT32_MAX             (4294967295UL)
+
+/* Minimum of signed integral types having a minimum size.  */
+# define INT_LEAST8_MIN         (-128)
+# define INT_LEAST16_MIN        (-32767-1)
+# define INT_LEAST32_MIN        (-2147483647L-1)
+/* Maximum of signed integral types having a minimum size.  */
+# define INT_LEAST8_MAX         (127)
+# define INT_LEAST16_MAX        (32767)
+# define INT_LEAST32_MAX        (2147483647L)
+
+/* Maximum of unsigned integral types having a minimum size.  */
+# define UINT_LEAST8_MAX        (255)
+# define UINT_LEAST16_MAX       (65535)
+# define UINT_LEAST32_MAX       (4294967295UL)
+
+/* Minimum of fast signed integral types having a minimum size.  */
+# define INT_FAST8_MIN          (-128)
+# define INT_FAST16_MIN         (-32767-1)
+# define INT_FAST32_MIN         (-2147483647L-1)
+
+/* Maximum of fast signed integral types having a minimum size.  */
+# define INT_FAST8_MAX          (127)
+# define INT_FAST16_MAX         (32767)
+# define INT_FAST32_MAX         (2147483647L)
+
+/* Maximum of fast unsigned integral types having a minimum size.  */
+# define UINT_FAST8_MAX         (255)
+# define UINT_FAST16_MAX        (65535)
+# define UINT_FAST32_MAX        (4294967295UL)
+
+/* Values to test for integral types holding `void *' pointer.  */
+# define INTPTR_MIN             (-2147483647L-1)
+# define INTPTR_MAX             (2147483647L)
+# define UINTPTR_MAX            (4294967295UL)
+
+/* Minimum for largest signed integral type.  */
+# define INTMAX_MIN             (-__INT32_C(-2147483647L)-1)
+/* Maximum for largest signed integral type.  */
+# define INTMAX_MAX             (__INT32_C(2147483647L))
+
+/* Maximum for largest unsigned integral type.  */
+# define UINTMAX_MAX            (__UINT32_C(4294967295UL))
+
+
+/* Limits of other integer types.  */
+
+/* Limits of `ptrdiff_t' type.  */
+# define PTRDIFF_MIN           (-2147483647L-1)
+# define PTRDIFF_MAX           (2147483647L)
+
+/* Limit of `size_t' type.  */
+# define SIZE_MAX               (65535)
+
+/* Signed.  */
+# define INT8_C(c)      c
+# define INT16_C(c)     c
+# define INT32_C(c)     c ## L
+
+/* Unsigned.  */
+# define UINT8_C(c)     c ## U
+# define UINT16_C(c)    c ## U
+# define UINT32_C(c)    c ## UL
+
+/* Maximal type.  */
+# define INTMAX_C(c)    c ## L
+# define UINTMAX_C(c)   c ## UL
+
+
+#endif /* stdint.h */
index 550a67aae3f6c8fd0de81065a76c796d918f5077..27328370853a0d298a4b5061b298589eac9637c4 100644 (file)
@@ -31,6 +31,9 @@
 
 #include <malloc.h>
 
+int abs(int j);
+long int labs(long int j);
+
 extern float atof (char *);
 extern int atoi (char *);
 extern long atol (char *);
index 95c12f110b3f8a20c4b1abd51fec47435e5ff443..96be13d95c9c7267e1441972a41c89a786b82ece 100644 (file)
@@ -30,8 +30,8 @@ static void dummy(void) _naked
        .globl  ___fsmul
 ___fsmul:
        // extract the two inputs, placing them into:
-       //      sign     exponent   mantiassa
-       //      ----     --------   ---------
+       //      sign     exponent   mantissa
+       //      ----     --------   --------
        //  a:  sign_a   exp_a      r4/r3/r2
        //  b:  sign_b   exp_b      r7/r6/r5
 
@@ -67,7 +67,7 @@ ___fsmul:
        //      r4 * r7                                 << 32
        //
        // This adds quite a bit of code, but it is a LOT faster
-       // that three calls to __mululong...
+       // than three calls to __mululong...
 
        // output goes into r4/r3/r2/r1/r0/xx
 
diff --git a/device/lib/abs.c b/device/lib/abs.c
new file mode 100644 (file)
index 0000000..a19a9b0
--- /dev/null
@@ -0,0 +1,27 @@
+/*-------------------------------------------------------------------------
+   abs.c: computes absolute value of an integer.
+
+   Copyright (C) 2004 - Maarten Brock, sourceforge.brock@dse.nl
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+-------------------------------------------------------------------------*/
+
+#include <stdlib.h>
+
+int abs(int j)
+{
+       return (j >= 0) ? j : -j;
+}
+//END OF MODULE
diff --git a/device/lib/labs.c b/device/lib/labs.c
new file mode 100644 (file)
index 0000000..3b64c07
--- /dev/null
@@ -0,0 +1,27 @@
+/*-------------------------------------------------------------------------
+   abs.c: computes absolute value of an integer.
+
+   Copyright (C) 2004 - Maarten Brock, sourceforge.brock@dse.nl
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+-------------------------------------------------------------------------*/
+
+#include <stdlib.h>
+
+long int labs(long int j)
+{
+       return (j >= 0) ? j : -j;
+}
+//END OF MODULE
index 0e3ae98252f26bf7302d994f9cd60d3c0be8b4d1..88bf7b03023c3b638cc4e9023872995059a67a61 100644 (file)
@@ -33,6 +33,8 @@ _gptrput
 _decdptr
 _bp
 _spx
+abs
+labs
 _atoi
 _atol
 calloc
index 4382d643a81ac63445ad71479cf70716fb688428..952b95476e7eb5c6291fcf34f4140a062976adef 100644 (file)
 /******************************************************************/
 /**                                                              **/
 /**    Major features.  These determine what capabilities your   **/
-/**    comiled printf_fast will have.                            **/
+/**    compiled printf_fast will have.                           **/
 /**                                                              **/
 /******************************************************************/
 
 // Include support for 32 bit base 10 integers (%ld and %lu).  Without
 // this, you won't be able to print 32 bit integers as base 10.  They
-// will appear in hexidecimal.
+// will appear in hexadecimal.
 #define LONG
 
 // Include support for floating point numbers (%f).  Don't forget to
@@ -88,6 +88,8 @@
 
 /* extern void putchar(char ); */
 
+// Warning: using static/global variables makes these functions NON-reentrant!
+// reentrant keyword is only used for parameter passing method
 
 static bit long_flag, short_flag, print_zero_flag, negative_flag;
 
@@ -134,7 +136,7 @@ static data unsigned int i2bcd_tmp;  // slow 32 int conversion needs temp space
 
 void PRINTF_FAST(code char *fmt, ...) reentrant
 {
-       fmt;    /* supress unreferenced variable warning */
+       fmt;    /* suppress unreferenced variable warning */
 
        _asm
 
index 4db9fe4fcfc78b269ffec436d41091143523f346..4d70072d05f71c549eeb69b9f985e703773e9293 100644 (file)
@@ -68,7 +68,7 @@
 
 void printf_tiny(code char *fmt, ...) reentrant
 {
-       fmt;    /* supress unreferenced variable warning */
+       fmt;    /* suppress unreferenced variable warning */
 
        _asm