* src/pic16/gen.c (pic16_freeAsmop): avoid NULL pointer dereference,
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 10 Feb 2009 21:14:15 +0000 (21:14 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 10 Feb 2009 21:14:15 +0000 (21:14 +0000)
  (genAssign): fixed for operands on the stack

* device/lib/pic16/libc/stdio/vfprintf.c,
  device/lib/pic16/configure.ac,
  device/lib/pic16/Makefile.common: add configurable support for
  printing floats via ./configure --enable-floats
* device/lib/pic16/configure,
  device/lib/pic16/Makefile.in,
  device/lib/pic16/libm/Makefile.in,
  device/lib/pic16/debug/Makefile.in,
  device/lib/pic16/libio/Makefile.in,
  device/lib/pic16/startup/Makefile.in,
  device/lib/pic16/libsdcc/Makefile.in,
  device/lib/pic16/libdev/Makefile.in,
  device/lib/pic16/libc/Makefile.in: regenerated
* doc/sdccman.lyx: documented float support and how to get it
* doc/Makefile.in: fixed race condition on parallel builds

* device/lib/pic16/libc/stdio/sprintf.c,
  device/lib/pic16/libc/stdio/vsprintf.c: do not mess up the user's
  pointer to the string buffer

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

18 files changed:
ChangeLog
device/lib/pic16/Makefile.common
device/lib/pic16/Makefile.in
device/lib/pic16/configure
device/lib/pic16/configure.ac
device/lib/pic16/debug/Makefile.in
device/lib/pic16/libc/Makefile.in
device/lib/pic16/libc/stdio/sprintf.c
device/lib/pic16/libc/stdio/vfprintf.c
device/lib/pic16/libc/stdio/vsprintf.c
device/lib/pic16/libdev/Makefile.in
device/lib/pic16/libio/Makefile.in
device/lib/pic16/libm/Makefile.in
device/lib/pic16/libsdcc/Makefile.in
device/lib/pic16/startup/Makefile.in
doc/Makefile.in
doc/sdccman.lyx
src/pic16/gen.c

index 6e92834b9f25307f6f6dad0ff81e4988cbe3328b..69cac246fbf0e39cd80f73245d84b5ab3870f326 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2008-02-10 Raphael Neider <rneider AT web.de>
+
+       * src/pic16/gen.c (pic16_freeAsmop): avoid NULL pointer dereference,
+         (genAssign): fixed for operands on the stack
+
+       * device/lib/pic16/libc/stdio/vfprintf.c,
+         device/lib/pic16/configure.ac,
+         device/lib/pic16/Makefile.common: add configurable support for
+         printing floats via ./configure --enable-floats
+       * device/lib/pic16/configure,
+         device/lib/pic16/Makefile.in,
+         device/lib/pic16/libm/Makefile.in,
+         device/lib/pic16/debug/Makefile.in,
+         device/lib/pic16/libio/Makefile.in,
+         device/lib/pic16/startup/Makefile.in,
+         device/lib/pic16/libsdcc/Makefile.in,
+         device/lib/pic16/libdev/Makefile.in,
+         device/lib/pic16/libc/Makefile.in: regenerated
+       * doc/sdccman.lyx: documented float support and how to get it
+       * doc/Makefile.in: fixed race condition on parallel builds
+
+       * device/lib/pic16/libc/stdio/sprintf.c,
+         device/lib/pic16/libc/stdio/vsprintf.c: do not mess up the user's
+         pointer to the string buffer
+
 2008-02-10 Borut Razem <borut.razem AT siol.net>
 
        * device/lib/printf_tiny.c: replaced non-C89 comments '//' with '/* */'
index a720ccde2f43c8e2e86ca08ac5766d6985746d00..55baa836ef497f738e20853b505df7df5cecd656 100644 (file)
@@ -25,6 +25,8 @@ AM_CFLAGS += --i-code-in-asm
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
 
+AM_CFLAGS += @USE_FLOATS@
+
 AM_CCASFLAGS =
 AM_CCASFLAGS += -I$(top_srcdir)/../../include/pic16
 AM_CCASFLAGS += -I$(srcdir)
index 0b37304243ecff4bf44528868575411e9256d27d..71089e47e0aa31635da48a3e455e4bab4fe3755a 100644 (file)
@@ -112,6 +112,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -159,10 +160,6 @@ SUBDIRS = debug libc libdev libio libm libsdcc startup
 #AM_CFLAGS += --debug-ralloc
 #AM_CFLAGS += --debug-xtra
 #AM_CFLAGS += --pcode-verbose
-AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
-       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
-       --fommit-frame-pointer --obanksel=9 --denable-peeps \
-       --optimize-cmp --optimize-df --i-code-in-asm
 
 #AM_CFLAGS += --nooverlay
 #AM_CFLAGS += --nogcse
@@ -171,6 +168,10 @@ AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
 #AM_CFLAGS += --noinduction
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
+AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
+       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
+       --fommit-frame-pointer --obanksel=9 --denable-peeps \
+       --optimize-cmp --optimize-df --i-code-in-asm @USE_FLOATS@
 AM_CCASFLAGS = -I$(top_srcdir)/../../include/pic16 -I$(srcdir)
 all: config.h
        $(MAKE) $(AM_MAKEFLAGS) all-recursive
index 90a278934447b5b4d5ccf1b0966f5a1971f0b145..5d18807c78b20afe66d215e5775f8f0df4f6a0c2 100755 (executable)
@@ -638,6 +638,7 @@ am__leading_dot
 AMTAR
 am__tar
 am__untar
+USE_FLOATS
 ARCH
 CC
 CFLAGS
@@ -1241,6 +1242,7 @@ if test -n "$ac_init_help"; then
 Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-floats         Enable output of float-values via printf().
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
 
@@ -2177,6 +2179,15 @@ esac
 
 libdir=$libdir/pic16
 
+USE_FLOATS="-DUSE_FLOATS=0"
+
+# Check whether --enable-floats was given.
+if test "${enable_floats+set}" = set; then
+  enableval=$enable_floats; if test "yes" = $enableval; then USE_FLOATS="-DUSE_FLOATS=1"; fi
+
+fi
+
+
 # Checks for programs.
 
 # The default architecture can be selected at configure time by setting the
@@ -3343,6 +3354,7 @@ am__leading_dot!$am__leading_dot$ac_delim
 AMTAR!$AMTAR$ac_delim
 am__tar!$am__tar$ac_delim
 am__untar!$am__untar$ac_delim
+USE_FLOATS!$USE_FLOATS$ac_delim
 ARCH!$ARCH$ac_delim
 CC!$CC$ac_delim
 CFLAGS!$CFLAGS$ac_delim
@@ -3369,7 +3381,7 @@ LIBOBJS!$LIBOBJS$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 83; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 84; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
index f7f8f94f90e90edaafe990628620c0e83f722bad..6ce003ec1663a9cd1e698c6a4561214aca1eafe6 100644 (file)
@@ -32,6 +32,13 @@ esac
 
 libdir=$libdir/pic16
 
+AC_SUBST([USE_FLOATS], ["-DUSE_FLOATS=0"])
+AC_ARG_ENABLE(
+    [floats],
+    AS_HELP_STRING([--enable-floats], [Enable output of float-values via printf().]),
+    [if test "yes" = $enableval; then USE_FLOATS="-DUSE_FLOATS=1"; fi]
+)
+
 # Checks for programs.
 
 # The default architecture can be selected at configure time by setting the
index f8790114cfba6135677e6a0868f265bde7f64c23..5512a136e8fb8c37bc2c9cf4d476f91aa3f5a07b 100644 (file)
@@ -109,6 +109,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -157,10 +158,6 @@ libdebug_a_SOURCES = gstack/gstack.c
 #AM_CFLAGS += --debug-ralloc
 #AM_CFLAGS += --debug-xtra
 #AM_CFLAGS += --pcode-verbose
-AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
-       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
-       --fommit-frame-pointer --obanksel=9 --denable-peeps \
-       --optimize-cmp --optimize-df --i-code-in-asm
 
 #AM_CFLAGS += --nooverlay
 #AM_CFLAGS += --nogcse
@@ -169,6 +166,10 @@ AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
 #AM_CFLAGS += --noinduction
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
+AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
+       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
+       --fommit-frame-pointer --obanksel=9 --denable-peeps \
+       --optimize-cmp --optimize-df --i-code-in-asm @USE_FLOATS@
 AM_CCASFLAGS = -I$(top_srcdir)/../../include/pic16 -I$(srcdir)
 all: all-am
 
index a0f0e567cf0055664f7b61f6485404242ae7bf00..3595819ab7c6a1a46a66ed5d2d0b496e94b71359 100644 (file)
@@ -136,6 +136,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -207,10 +208,6 @@ libc18f_a_SOURCES = ctype/iscntrl.c ctype/isdigit.c ctype/isgraph.c \
 #AM_CFLAGS += --debug-ralloc
 #AM_CFLAGS += --debug-xtra
 #AM_CFLAGS += --pcode-verbose
-AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
-       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
-       --fommit-frame-pointer --obanksel=9 --denable-peeps \
-       --optimize-cmp --optimize-df --i-code-in-asm
 
 #AM_CFLAGS += --nooverlay
 #AM_CFLAGS += --nogcse
@@ -219,6 +216,10 @@ AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
 #AM_CFLAGS += --noinduction
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
+AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
+       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
+       --fommit-frame-pointer --obanksel=9 --denable-peeps \
+       --optimize-cmp --optimize-df --i-code-in-asm @USE_FLOATS@
 AM_CCASFLAGS = -I$(top_srcdir)/../../include/pic16 -I$(srcdir)
 all: all-am
 
index b7f5a031d313bdb9ca941e8fea154496462c73ba..137a1929085bde4badb378e1660e75d45ca51bff 100644 (file)
@@ -39,8 +39,8 @@ sprintf (char *ebuf, char *fmt, ...)
   va_list ap;
 
   ap = va_start (ap, fmt);
-  i = vfprintf ((FILE *) &ebuf, fmt, ap);
-  *ebuf = '\0';
+  i = vfprintf ((FILE *) ebuf, fmt, ap);
+  ebuf[i] = '\0';
 
   return i;
 }
index 304bb01b03d522e5f5db7a9b94fe0f24a855138e..fc2433434d9b40e1ac7c2bc05672d451808357e6 100644 (file)
  * Costs ~25 code words
  */
 #define FLOAT_PLACEHOLDER
+/*
+ * With this macro defined, printing floats will work.
+ * This also enables PRECISION and disables FLOAT_PLACEHOLDER.
+ */
+#if defined(USE_FLOATS)
+  /* The configure script always defines USE_FLOATS to 0 or 1. */
+# if USE_FLOATS < 1
+#  undef USE_FLOATS
+# endif
+#else
+/* # define USE_FLOATS */
+#endif
+
+#if defined(USE_FLOATS)
+#define PRECISION
+#undef FLOAT_PLACEHOLDER
+#endif
 /*
  * This macro enables the use of the 'b' binary specifier and
  * the use of "%b", "%hb" and "%lb"
@@ -143,7 +160,7 @@ vfprintf (FILE * stream, const char *fmt, va_list ap)
   unsigned char flong;
   unsigned char fstr;
   unsigned char fchar;
-#ifdef FLOAT_PLACEHOLDER
+#if defined(FLOAT_PLACEHOLDER) || defined(USE_FLOATS)
   unsigned char ffloat;
 #endif
   unsigned char nosign;
@@ -165,6 +182,13 @@ vfprintf (FILE * stream, const char *fmt, va_list ap)
   char *str, *ch;
   long val;
   char buffer[BUF_SIZE];
+  char *stringbuffer;
+
+  if (0x80 == (unsigned char)(((unsigned long)stream) >> 16)) {
+    /* strmputchar will modify *(char **)stream, thus confusing the user */
+    stringbuffer = (char *) stream;
+    stream = (FILE *) &stringbuffer;
+  }
 
 #if _DEBUG
   io_str ("vfprintf: ");
@@ -182,7 +206,7 @@ vfprintf (FILE * stream, const char *fmt, va_list ap)
           flong = 0;
           fstr = 0;
           fchar = 0;
-#ifdef FLOAT_PLACEHOLDER
+#if defined(FLOAT_PLACEHOLDER) || defined(USE_FLOATS)
           ffloat = 0;
 #endif
           nosign = 0;
@@ -302,13 +326,10 @@ vfprintf (FILE * stream, const char *fmt, va_list ap)
           else if (*ch == 'b')
             radix = 2;
 #endif
-#ifdef FLOAT_PLACEHOLDER
+#if defined(FLOAT_PLACEHOLDER) || defined(USE_FLOATS)
           else if (*ch == 'f')
             {
               ffloat = 1;
-# ifdef PRECISION
-              precision = -1;
-# endif
             }
 #endif
 #ifdef EXTRA_INTEGER
@@ -331,13 +352,24 @@ vfprintf (FILE * stream, const char *fmt, va_list ap)
           if (fstr)
             {
               str = va_arg (ap, char *);
-#ifdef FLOAT_PLACEHOLDER
+#if defined(USE_FLOATS)
+            }
+          else if (ffloat)
+            {
+              float f = va_arg(ap, float);
+              str = buffer;
+              x_ftoa (f, buffer, BUF_SIZE, precision);
+              precision = -1;
+#elif defined(FLOAT_PLACEHOLDER)
             }
           else if (ffloat)
             {
               str = "<NO FLOAT>";
               va_arg (ap, float);
-#endif
+#ifdef PRECISION
+              precision = -1;
+#endif /* PRECISION */
+#endif /* FLOAT_PLACEHOLDER */
             }
           else
             {
@@ -426,6 +458,10 @@ vfprintf (FILE * stream, const char *fmt, va_list ap)
               __stream_putchar (stream, radix);
               ++str;
               ++count;
+              if (fieldwidth)
+                {
+                  fieldwidth--;
+                }
             }
 #ifdef FIELD_WIDTH
           //Right padding (with spaces)
index 16e930d4bc51cce7aebff96ff802095f04316bae..57259e51e0685ddbdf6109bed55ab57728a6a62f 100644 (file)
@@ -37,8 +37,8 @@ vsprintf (char *ebuf, const char *fmt, va_list ap)
 {
   unsigned int i;
 
-  i = vfprintf((FILE *) &ebuf, fmt, ap);
-  *ebuf = '\0';
+  i = vfprintf((FILE *) ebuf, fmt, ap);
+  ebuf[i] = '\0';
 
   return i;
 }
index 10ec93052441ad199f761485c35caf07fdc5486b..3dfc6193dbaa5581d08536d21b2c7ef30e3454ef 100644 (file)
@@ -489,6 +489,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -713,10 +714,6 @@ libdev18f97j60_a_CFLAGS = -p18f97j60 $(AM_CFLAGS)
 #AM_CFLAGS += --debug-ralloc
 #AM_CFLAGS += --debug-xtra
 #AM_CFLAGS += --pcode-verbose
-AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
-       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
-       --fommit-frame-pointer --obanksel=9 --denable-peeps \
-       --optimize-cmp --optimize-df --i-code-in-asm
 
 #AM_CFLAGS += --nooverlay
 #AM_CFLAGS += --nogcse
@@ -725,6 +722,10 @@ AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
 #AM_CFLAGS += --noinduction
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
+AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
+       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
+       --fommit-frame-pointer --obanksel=9 --denable-peeps \
+       --optimize-cmp --optimize-df --i-code-in-asm @USE_FLOATS@
 AM_CCASFLAGS = -I$(top_srcdir)/../../include/pic16 -I$(srcdir)
 all: all-am
 
index c4714447db20f8f6f11f63b1a87ebfee8f5be3a0..bede7aca570e0d24443f1379efef2e2dc2f7269c 100644 (file)
@@ -2274,6 +2274,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -3001,10 +3002,6 @@ libio18f97j60_a_CFLAGS = -p18f97j60 $(AM_CFLAGS)
 #AM_CFLAGS += --debug-ralloc
 #AM_CFLAGS += --debug-xtra
 #AM_CFLAGS += --pcode-verbose
-AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
-       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
-       --fommit-frame-pointer --obanksel=9 --denable-peeps \
-       --optimize-cmp --optimize-df --i-code-in-asm
 
 #AM_CFLAGS += --nooverlay
 #AM_CFLAGS += --nogcse
@@ -3013,6 +3010,10 @@ AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
 #AM_CFLAGS += --noinduction
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
+AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
+       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
+       --fommit-frame-pointer --obanksel=9 --denable-peeps \
+       --optimize-cmp --optimize-df --i-code-in-asm @USE_FLOATS@
 AM_CCASFLAGS = -I$(top_srcdir)/../../include/pic16 -I$(srcdir)
 all: all-am
 
index 14490c67c1414dddcbb64bc225add8e99076c8d7..81ab7918fc12d4bae60928c6ba57ea300cf68538 100644 (file)
@@ -117,6 +117,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -168,10 +169,6 @@ libm18f_a_SOURCES = acosf.c asincosf.c asinf.c atan2f.c atanf.c \
 #AM_CFLAGS += --debug-ralloc
 #AM_CFLAGS += --debug-xtra
 #AM_CFLAGS += --pcode-verbose
-AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
-       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
-       --fommit-frame-pointer --obanksel=9 --denable-peeps \
-       --optimize-cmp --optimize-df --i-code-in-asm
 
 #AM_CFLAGS += --nooverlay
 #AM_CFLAGS += --nogcse
@@ -180,6 +177,10 @@ AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
 #AM_CFLAGS += --noinduction
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
+AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
+       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
+       --fommit-frame-pointer --obanksel=9 --denable-peeps \
+       --optimize-cmp --optimize-df --i-code-in-asm @USE_FLOATS@
 AM_CCASFLAGS = -I$(top_srcdir)/../../include/pic16 -I$(srcdir)
 all: all-am
 
index 380a18f76ce60e7bf734a00f38e1229aa874f239..874f1bf36afcc6af66b54ad35a8b1e0ebdb4d17d 100644 (file)
@@ -136,6 +136,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -208,10 +209,6 @@ libsdcc_a_SOURCES = char/divschar.c char/divuchar.c char/modschar.c \
 #AM_CFLAGS += --debug-ralloc
 #AM_CFLAGS += --debug-xtra
 #AM_CFLAGS += --pcode-verbose
-AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
-       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
-       --fommit-frame-pointer --obanksel=9 --denable-peeps \
-       --optimize-cmp --optimize-df --i-code-in-asm
 
 #AM_CFLAGS += --nooverlay
 #AM_CFLAGS += --nogcse
@@ -220,6 +217,10 @@ AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
 #AM_CFLAGS += --noinduction
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
+AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
+       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
+       --fommit-frame-pointer --obanksel=9 --denable-peeps \
+       --optimize-cmp --optimize-df --i-code-in-asm @USE_FLOATS@
 AM_CCASFLAGS = -I$(top_srcdir)/../../include/pic16 -I$(srcdir)
 all: all-am
 
index 0469416f4bec9124699af06ac0862e054d5cda84..d39a403815a067712c53d9c706bddec276f6d733 100644 (file)
@@ -121,6 +121,7 @@ RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -177,10 +178,6 @@ crt_DATA = crt0.o crt0i.o crt0iz.o
 #AM_CFLAGS += --debug-ralloc
 #AM_CFLAGS += --debug-xtra
 #AM_CFLAGS += --pcode-verbose
-AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
-       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
-       --fommit-frame-pointer --obanksel=9 --denable-peeps \
-       --optimize-cmp --optimize-df --i-code-in-asm
 
 #AM_CFLAGS += --nooverlay
 #AM_CFLAGS += --nogcse
@@ -189,6 +186,10 @@ AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
 #AM_CFLAGS += --noinduction
 #AM_CFLAGS += --nojtbound
 #AM_CFLAGS += --noloopreverse
+AM_CFLAGS = --std-c99 --asm="$(CCAS)" -I. \
+       -I$(top_srcdir)/../../include/pic16 -Wa,-q \
+       --fommit-frame-pointer --obanksel=9 --denable-peeps \
+       --optimize-cmp --optimize-df --i-code-in-asm @USE_FLOATS@
 AM_CCASFLAGS = -I$(top_srcdir)/../../include/pic16 -I$(srcdir)
 all: all-am
 
index 3d8274f0874a08a5169c5769b3353ff5d25aea6d..b8e3c26fac85b606e1c71d9224f3849a78bde2e7 100644 (file)
@@ -103,9 +103,9 @@ $(MANUAL).html/index.html: $(MANUAL).tex $(MANUAL).aux ;#$(MANUAL).ind $(MANUAL)
        $(PDFLATEX) $* $(QUIET)
        [ ! -e "$*.idx" ] || $(MAKEINDEX) $* $(QUIET)
        $(PDFLATEX) $* $(QUIET)
-       $(PDFOPT) $*.pdf tmp.pdf
+       $(PDFOPT) $*.pdf $*-tmp.pdf
        rm $*.pdf
-       mv tmp.pdf $*.pdf
+       mv $*-tmp.pdf $*.pdf
 
 archive: all
        rm -rf sdcc-doc sdcc-doc.tar.bz2
index 801cffb5ee50c7bece94800a704a90dee2e0189d..a949aecabd82e4ea46571492c5287d99bde66efc 100644 (file)
@@ -1,4 +1,4 @@
-#LyX 1.5.7 created this file. For more info see http://www.lyx.org/
+#LyX 1.5.6 created this file. For more info see http://www.lyx.org/
 \lyxformat 276
 \begin_document
 \begin_header
@@ -21001,7 +21001,7 @@ name "printf()"
 printf_large.c
 \family default
  does not support float (except on ds390).
- To enable this recompile it with the option 
+ To enable this, recompile it with the option 
 \emph on
 -
 \begin_inset ERT
@@ -21049,6 +21049,13 @@ name "-\\/-model-large"
 
 \emph default
  for the mcs51 port, since this uses a lot of memory.
+ To enable float support for the pic16 targets, see 
+\begin_inset LatexCommand ref
+reference "sub:pic16Libraries"
+
+\end_inset
+
+.
 \end_layout
 
 \begin_layout Standard
@@ -27254,9 +27261,19 @@ Building the libraries
 Before using SDCC/pic16 there are some libraries that need to be compiled.
  This process is done automatically if gputils are found at SDCC's compile
  time.
- Should you require to rebuild the pic16 libraries manually, these are the
- steps required to do so under Linux or Mac OS X (cygwin might work as well,
- but is untested):
+ Should you require to rebuild the pic16 libraries manually (e.g.
+ in order to enable output of float values
+\begin_inset LatexCommand index
+name "Floating point support"
+
+\end_inset
+
+ via 
+\family typewriter
+printf()
+\family default
+, see below), these are the steps required to do so under Linux or Mac OS
+ X (cygwin might work as well, but is untested):
 \end_layout
 
 \begin_layout LyX-Code
@@ -27295,6 +27312,54 @@ cd device/include
 su -c 'make install'     # install the headers, you need the root password
 \end_layout
 
+\begin_layout Subsubsection*
+Output of float values via printf()
+\end_layout
+
+\begin_layout Standard
+The library is normally built without support for displaying float values,
+ only <NO FLOAT> will appear instead of the value.
+ To change this, rebuild the library as stated above, but call 
+\family typewriter
+./configure.gnu --enable-floats 
+\family default
+instead of just 
+\family typewriter
+./configure.gnu
+\family default
+.
+ Also make sure that at least 
+\family typewriter
+libc/stdio/vfprintf.c
+\family default
+ is actually recompiled, e.g.
+ by 
+\family typewriter
+touch
+\family default
+ing it after the 
+\family typewriter
+configure
+\family default
+ run or deleting its 
+\family typewriter
+.o
+\family default
+ file.
+\end_layout
+
+\begin_layout Standard
+The more common appraoch of compiling 
+\family typewriter
+vfprintf.c
+\family default
+ manually with 
+\family typewriter
+-DUSE_FLOATS=1
+\family default
+ should also work, but is untested.
+\end_layout
+
 \begin_layout Subsection
 Adding New Devices to the Port
 \end_layout
index 358a2e266e2c18fa9f460776978fbc946a6e114b..fa1d7a014660d3255e42ada3791a871ae15c8aa0 100644 (file)
@@ -1163,7 +1163,7 @@ void pic16_freeAsmop (operand *op, asmop *aaop, iCode *ic, bool pop)
                   }
                 }
 
-                {
+                if (_G.sregsAllocSet) {
                   regs *sr;
 
                     _G.sregsAllocSet = reverseSet( _G.sregsAllocSet );
@@ -9366,8 +9366,8 @@ static void genAssign (iCode *ic)
     pic16_addSign(result, AOP_SIZE(right), !IS_UNSIGNED(operandType(right)));
 
 release:
-  pic16_freeAsmop (right,NULL,ic,FALSE);
   pic16_freeAsmop (result,NULL,ic,TRUE);
+  pic16_freeAsmop (right,NULL,ic,FALSE);
 }
 
 /*-----------------------------------------------------------------*/