+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 '/* */'
#AM_CFLAGS += --nojtbound
#AM_CFLAGS += --noloopreverse
+AM_CFLAGS += @USE_FLOATS@
+
AM_CCASFLAGS =
AM_CCASFLAGS += -I$(top_srcdir)/../../include/pic16
AM_CCASFLAGS += -I$(srcdir)
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
#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
#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
AMTAR
am__tar
am__untar
+USE_FLOATS
ARCH
CC
CFLAGS
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
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
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
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
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
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
#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
#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
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
#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
#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
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;
}
* 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"
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;
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: ");
flong = 0;
fstr = 0;
fchar = 0;
-#ifdef FLOAT_PLACEHOLDER
+#if defined(FLOAT_PLACEHOLDER) || defined(USE_FLOATS)
ffloat = 0;
#endif
nosign = 0;
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
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
{
__stream_putchar (stream, radix);
++str;
++count;
+ if (fieldwidth)
+ {
+ fieldwidth--;
+ }
}
#ifdef FIELD_WIDTH
//Right padding (with spaces)
{
unsigned int i;
- i = vfprintf((FILE *) &ebuf, fmt, ap);
- *ebuf = '\0';
+ i = vfprintf((FILE *) ebuf, fmt, ap);
+ ebuf[i] = '\0';
return i;
}
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
#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
#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
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
#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
#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
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
#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
#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
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
#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
#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
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+USE_FLOATS = @USE_FLOATS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
#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
#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
$(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
-#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
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
\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
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
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
}
}
- {
+ if (_G.sregsAllocSet) {
regs *sr;
_G.sregsAllocSet = reverseSet( _G.sregsAllocSet );
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);
}
/*-----------------------------------------------------------------*/