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

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

Re: [avr-gcc-list] Problem where R0 gets used


From: Erik Christiansen
Subject: Re: [avr-gcc-list] Problem where R0 gets used
Date: Fri, 18 Jan 2008 17:02:56 +1100
User-agent: Mutt/1.5.9i

On Fri, Jan 18, 2008 at 12:24:29AM -0500, Andrew Hutchinson wrote:
> I think I have found a bug with avr register allocation.

Maybe not. ;-)

...
> So R0 got trashed.
> 
> There will be other examples where this could happen as R0 is used is 
> quite a few places to help assembler. 

But the avr ABI defines it as volatile, as I understand it. At
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_reg_usage we
have:

>>>
   r0 - temporary register, can be clobbered by any C code (except
   interrupt handlers which save it), may be used to remember something
   for a while within one piece of assembler code
<<<

Looks like we have licence to trash it.

> 
> I can only assume at this time that the same could happen to R1.

Nope, not a safe assumption. It must be restored if fiddled. It is
"assumed to be always zero in any C code".

Erik




reply via email to

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