fixed bug 1255403
authorpjs <pjs@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 14 Mar 2008 22:14:33 +0000 (22:14 +0000)
committerpjs <pjs@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 14 Mar 2008 22:14:33 +0000 (22:14 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5100 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
device/lib/printf_fast.c

index 643ed9086a976bfac2ba8adbedf11cd43868021c..94037fd0a822ddee46bfd23b516716d14a3eda6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-03-14 Paul Stoffregen <paul AT pjrc.com>
+
+       * device/lib/printf_fast.c: fixed bug 1255403
+
 2008-03-14 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * doc/sdccman.lyx: enhanced paragraph about bankswitching for mcs51
index 028ee2b176077ffe3b193e28324ce3405b20a93e..3e20d343b9da77cf404da4f968f0561285dfca48 100644 (file)
@@ -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