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

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

Re: [avr-gcc-list] Broken strtoul() and ldiv()


From: Matthew Lee
Subject: Re: [avr-gcc-list] Broken strtoul() and ldiv()
Date: Mon, 11 Mar 2002 11:18:30 +1100

My original reply got lost in the ether.  Here it is again, in case
anyone is interested:


Geoffrey,

I did encounter a similar problem to this, and was convinced (for a
while) that strtoul() was broken.

In my situation, though, it turned out not to be the case.

Calls to strtoul() were being interrupted and my ISR (which was written
in assembler) did not restore the value of register R1 to 0x00.  GCC
assumes that (for C code) the value in R1 is always 0x00.

When the ISR returned back to strtoul(), this assumption was not longer
true and things started to go wrong.  The fix was to have my ISR write
0x00 to R1 as it exits.

I don't know if this could be your problem, but worth keeping in mind.

Regards,
Matt



Geoffrey Wossum wrote:
> 
> Hi,
> 
> All recent (and probably old versions, too) of avr-libc have broken
> strtoul.  I always get 0xffffffff out.  The problem appears to be that
> ldiv() is broken.  If I change the conditionals in strtoul() around so
> that it uses '/' and '%' instead of ldiv(), it works.  This leads me to
> believe that ldiv() is broken.
> 
> Checking the ldiv() source file, it just jumps to __divmodsi4 in libgcc.
> Perhaps either this isn't the right thing to do, or __divmodsi4 is broken.
> 
> BTW, I'm using the BSD version of strtoul(), not the GNU.  The GNU one
> problem doesn't work either because it uses ldiv() as well.
> 
> Anyone else observe this problem or know what's going on?
> 
> ---
> Geoffrey Wossum
> Project AKO - http://ako.sf.net
> 
> avr-gcc-list at http://avr1.org
avr-gcc-list at http://avr1.org



reply via email to

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