From 64742aae9bd77138ac62f27dbf8557a99f2f8292 Mon Sep 17 00:00:00 2001 From: pjs Date: Fri, 14 Mar 2008 22:14:33 +0000 Subject: [PATCH] fixed bug 1255403 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5100 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 ++++ device/lib/printf_fast.c | 25 ++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 643ed908..94037fd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-03-14 Paul Stoffregen + + * device/lib/printf_fast.c: fixed bug 1255403 + 2008-03-14 Maarten Brock * doc/sdccman.lyx: enhanced paragraph about bankswitching for mcs51 diff --git a/device/lib/printf_fast.c b/device/lib/printf_fast.c index 028ee2b1..3e20d343 100644 --- a/device/lib/printf_fast.c +++ b/device/lib/printf_fast.c @@ -414,6 +414,11 @@ printf_uint_ck8: /* print the digit zero and skip all the hard work! */ mov a, r1 jnz printf_uint_begin +#ifdef FLOAT + /* never use the "just print zero" shortcut if we're printing */ + /* the integer part of a float (fixes bug 1255403) */ + jb _continue_float, printf_uint_begin +#endif #ifdef FIELD_WIDTH jnb _field_width_flag, printf_uint_zero mov a, _field_width @@ -425,14 +430,8 @@ printf_uint_zero: //mov a, #'0' mov a, #48 lcall printf_putchar -#ifdef FLOAT - jnb _continue_float, 0001$ - ret -0001$: -#endif ljmp printf_main_loop - printf_uint_begin: push dpl push dph @@ -486,7 +485,7 @@ printf_uifw_8: jnz printf_uifw_sub dec r1 printf_uifw_sub: - ;r1 has the number of digits for the number + //r1 has the number of digits for the number mov a, _field_width mov c, _negative_flag subb a, r1 @@ -766,8 +765,12 @@ print_float_default_width: // default fractional field width (between 0 to 7) // attempt to scale the default number of fractional digits // based on the magnitude of the float - mov ar1, r0 // r0 points to first byte of float - dec r1 // r1 points to second byte of float + mov a, @r0 + anl a, #0x7F // ignore sign bit + mov r2, a // r2 is first byte of float + dec r0 + mov ar3, @r0 // r3 is second byte of float + inc r0 mov r6, dpl mov r7, dph mov dptr, #_float_range_table @@ -775,11 +778,11 @@ print_float_default_width: print_float_default_loop: clr a movc a, @a+dptr - add a, @r1 + add a, r3 inc dptr clr a movc a, @a+dptr - addc a, @r0 + addc a, r2 jnc print_float_default_done inc dptr djnz r5, print_float_default_loop -- 2.30.2