From 6c76149da648ea3e88c8e3106cac29ee714c5549 Mon Sep 17 00:00:00 2001 From: pjs Date: Tue, 28 Dec 2004 11:17:44 +0000 Subject: [PATCH] Added printf_fast_f. Same as printf_fast, but with floating point enabled git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3617 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 7 +++++++ device/include/stdio.h | 1 + device/lib/Makefile.in | 3 ++- device/lib/libsdcc.lib | 1 + device/lib/printf_fast.c | 32 ++++++++++++++++++-------------- device/lib/printf_fast_f.c | 7 +++++++ 6 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 device/lib/printf_fast_f.c diff --git a/ChangeLog b/ChangeLog index be293765..8259c547 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-12-28 Paul Stoffregen + + * device/lib/printf_fast_f.c: same as printf_fast, but + with floating point enabled + * device/lib/printf_fast.c: minor tweaks + * device/include/stdio.h: add printf_fast_f + 2004-12-27 Paul Stoffregen * src/SDCCmain.c: make --float-reent default for mcs51 diff --git a/device/include/stdio.h b/device/include/stdio.h index c601ee8c..d96ebc28 100644 --- a/device/include/stdio.h +++ b/device/include/stdio.h @@ -60,6 +60,7 @@ extern void putchar(char); #ifdef __mcs51 extern void printf_fast(code char *fmt, ...) _REENTRANT; +extern void printf_fast_f(code char *fmt, ...) _REENTRANT; extern void printf_tiny(code char *fmt, ...) _REENTRANT; #endif diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index 1e642e83..97c226b4 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -65,7 +65,8 @@ SOURCES = _atof.c _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \ calloc.c malloc.c realloc.c free.c \ serial.c ser_ir.c printfl.c \ printf_large.c sprintf.c vprintf.c puts.c gets.c \ - assert.c time.c printf_fast.c printf_tiny.c bpx.c \ + printf_fast.c printf_fast_f.c printf_tiny.c \ + assert.c time.c bpx.c \ _fsget1arg.c _fsget2args.c _fsnormalize.c \ _fsreturnval.c _fsrshift.c _fsswapargs.c \ fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \ diff --git a/device/lib/libsdcc.lib b/device/lib/libsdcc.lib index 00873b43..0e3ae982 100644 --- a/device/lib/libsdcc.lib +++ b/device/lib/libsdcc.lib @@ -48,6 +48,7 @@ gets printfl printf_large printf_fast +printf_fast_f printf_tiny sprintf vprintf diff --git a/device/lib/printf_fast.c b/device/lib/printf_fast.c index d05457ee..698f9fa1 100644 --- a/device/lib/printf_fast.c +++ b/device/lib/printf_fast.c @@ -115,7 +115,11 @@ static data unsigned int i2bcd_tmp; // slow 32 int conversion needs temp space -void printf_fast(code char *fmt, ...) reentrant +#ifndef PRINTF_FAST +#define PRINTF_FAST printf_fast +#endif + +void PRINTF_FAST(code char *fmt, ...) reentrant { fmt; /* supress unreferenced variable warning */ @@ -1473,24 +1477,24 @@ printf_end: */ #if 0 -code unsigned char int2bcd_0[] = { +static code unsigned char int2bcd_0[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15}; -code unsigned char int2bcd_1[] = { +static code unsigned char int2bcd_1[] = { 0x00, 0x16, 0x32, 0x48, 0x64, 0x80, 0x96, 0x12, 0x28, 0x44, 0x60, 0x76, 0x92, 0x08, 0x24, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02}; #endif -code unsigned char int2bcd_2[] = { +static code unsigned char int2bcd_2[] = { 0x00, 0x56, 0x12, 0x68, 0x24, 0x80, 0x36, 0x92, 0x48, 0x04, 0x60, 0x16, 0x72, 0x28, 0x84, 0x40, 0x00, 0x02, 0x05, 0x07, 0x10, 0x12, 0x15, 0x17, 0x20, 0x23, 0x25, 0x28, 0x30, 0x33, 0x35, 0x38}; -code unsigned char int2bcd_3[] = { +static code unsigned char int2bcd_3[] = { 0x00, 0x96, 0x92, 0x88, 0x84, 0x80, 0x76, 0x72, 0x68, 0x64, 0x60, 0x56, 0x52, 0x48, 0x44, 0x40, 0x00, 0x40, 0x81, 0x22, 0x63, 0x04, 0x45, 0x86, @@ -1499,7 +1503,7 @@ code unsigned char int2bcd_3[] = { 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x06}; #ifdef LONG -code unsigned char int2bcd_4[] = { +static code unsigned char int2bcd_4[] = { 0x00, 0x36, 0x72, 0x08, 0x44, 0x80, 0x16, 0x52, 0x88, 0x24, 0x60, 0x96, 0x32, 0x68, 0x04, 0x40, 0x00, 0x55, 0x10, 0x66, 0x21, 0x76, 0x32, 0x87, @@ -1507,7 +1511,7 @@ code unsigned char int2bcd_4[] = { 0x00, 0x06, 0x13, 0x19, 0x26, 0x32, 0x39, 0x45, 0x52, 0x58, 0x65, 0x72, 0x78, 0x85, 0x91, 0x98}; -code unsigned char int2bcd_5[] = { +static code unsigned char int2bcd_5[] = { 0x00, 0x76, 0x52, 0x28, 0x04, 0x80, 0x56, 0x32, 0x08, 0x84, 0x60, 0x36, 0x12, 0x88, 0x64, 0x40, 0x00, 0x85, 0x71, 0x57, 0x43, 0x28, 0x14, 0x00, @@ -1517,7 +1521,7 @@ code unsigned char int2bcd_5[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15}; -code unsigned char int2bcd_6[] = { +static code unsigned char int2bcd_6[] = { 0x00, 0x16, 0x32, 0x48, 0x64, 0x80, 0x96, 0x12, 0x28, 0x44, 0x60, 0x76, 0x92, 0x08, 0x24, 0x40, 0x00, 0x72, 0x44, 0x16, 0x88, 0x60, 0x32, 0x05, @@ -1529,7 +1533,7 @@ code unsigned char int2bcd_6[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02}; -code unsigned char int2bcd_7[] = { +static code unsigned char int2bcd_7[] = { 0x00, 0x56, 0x12, 0x68, 0x24, 0x80, 0x36, 0x92, 0x48, 0x04, 0x60, 0x16, 0x72, 0x28, 0x84, 0x40, 0x00, 0x54, 0x09, 0x63, 0x18, 0x72, 0x27, 0x81, @@ -1566,7 +1570,7 @@ code unsigned char int2bcd_7[] = { */ #ifdef LONG -code unsigned char int2bcd[] = { +static code unsigned char int2bcd[] = { 0x01, 0x00, 0x00, 0x00, 0x00, // 1 0x02, 0x00, 0x00, 0x00, 0x00, // 2 0x04, 0x00, 0x00, 0x00, 0x00, // 4 @@ -1601,7 +1605,7 @@ code unsigned char int2bcd[] = { 0x48, 0x36, 0x48, 0x47, 0x21 // 2147483648 }; #else // not LONG -code unsigned char int2bcd[] = { +static code unsigned char int2bcd[] = { 0x01, 0x00, 0x00, // 1 0x02, 0x00, 0x00, // 2 0x04, 0x00, 0x00, // 4 @@ -1642,7 +1646,7 @@ code unsigned char int2bcd[] = { * } */ -code unsigned char frac2bcd[] = { +static code unsigned char frac2bcd[] = { 0x00, 0x00, 0x00, 0x50, // 0.500000000000000 0.50000000 0x00, 0x00, 0x00, 0x25, // 0.250000000000000 0.75000000 0x00, 0x00, 0x50, 0x12, // 0.125000000000000 0.87500000 @@ -1684,7 +1688,7 @@ code unsigned char frac2bcd[] = { // 100.0 - 999.99 2 100.0 = 0x42C80000 42C8 // 1000 - 9999.9 1 1000 = 0x447A0000 447A // 10000+ 0 10000 = 0x461C4000 461C -code unsigned int float_range_table[] = { +static code unsigned int float_range_table[] = { 65536 - 0x3A83, 65536 - 0x3C23, 65536 - 0x3DCC, @@ -1710,7 +1714,7 @@ code unsigned int float_range_table[] = { * } */ -code unsigned char frac2bcd[] = { +static code unsigned char frac2bcd[] = { 0x00, 0x50, // 0.500000000000000 0.5000 0x00, 0x25, // 0.250000000000000 0.7500 0x50, 0x12, // 0.125000000000000 0.8750 diff --git a/device/lib/printf_fast_f.c b/device/lib/printf_fast_f.c new file mode 100644 index 00000000..eb914592 --- /dev/null +++ b/device/lib/printf_fast_f.c @@ -0,0 +1,7 @@ +// Same as printf_fast, but with floating point enabled + +#define FLOAT +#define PRINTF_FAST printf_fast_f + +#include "printf_fast.c" + -- 2.30.2