avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Bug in itoa()


From: Richter_Matthias
Subject: [avr-gcc-list] Bug in itoa()
Date: Tue, 17 Apr 2001 08:28:42 +0200

Hello list!

Some weeks ago, I wrote about an "undefined reference to '_udivhi3'" in
itoa(). 
This problem has gone with avr-libc 20010331.
Now, there is another (new?) bug in itoa(): It runs into infinite loops
for some input values. 
To correct this, the radix value has to be copied to r23:r22 (divisor
registers for _udivmodhi4) before every iteration (not only before the
first iteration).

cut: ----------------------------------------------(in
src/misc/itoa.S)-----
        mov     rP3, rP5        ; radix
        clr     rP2
        clr     rSI1            ; count, clear for later
        clr     rSI0            ; minus flag

        cpi     rP3, 2          ; no radix < 2
        brlt    terminate
        cpi     rP3, 10         ; decimal number ?
        brne    divide_loop
        and     rP0, rP0        ; sign of value ?
        brge    divide_loop
        com     rP0             ; make positive
        neg     rP1
        sbci    rP0,0xff
        ldi     rSI0, '-'       ; store sign
divide_loop:
                                 ; dividend in r25:r24,   divisor in r23:r22
        XCALL   _U(__udivmodhi4) ; quotient in r23:r22, remainder in r25:r24
-----------------------------------------------------------------------------   

insert:
---------------------------------------------------------------------
        clr     rSI1            ; count, clear for later
        clr     rSI0            ; minus flag

        cpi     rP5, 2          ; no radix < 2
        brlt    terminate
        cpi     rP5, 10         ; decimal number ?
        brne    divide_loop
        and     rP0, rP0        ; sign of value ?
        brge    divide_loop
        com     rP0             ; make positive
        neg     rP1
        sbci    rP0,0xff
        ldi     rSI0, '-'       ; store sign
divide_loop:
        mov     rP3, rP5        ; radix
        clr     rP2
        XCALL   _U(__udivmodhi4) ; dividend in r25:r24,   divisor in r23:r22
                                 ; quotient in r23:r22, remainder in
r25:r24
-----------------------------------------------------------------------------

With this fix, it seems to work correct.

Greetings,

Matthias



reply via email to

[Prev in Thread] Current Thread [Next in Thread]