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

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

[avr-gcc-list] Re: AVR-GCC-list Digest, Vol 19, Issue 16


From: Björn Haase
Subject: [avr-gcc-list] Re: AVR-GCC-list Digest, Vol 19, Issue 16
Date: Sat, 19 Aug 2006 19:47:21 +0200
User-agent: KMail/1.7.1

>> Is there any particular set of registers that are better suited to
>> be fixed than others ?
>
>Walking from r2 up to at most r15 is a good idea.  r0 and r1 are
>needed internally by AVR-GCC, and must not be reused.

IIMHO, only r4-r7 are *guaranteed* to be safe and, IMO, r2-r7 are safe in 
practice. 
r0 and r1 are used as scratch registers all around the code and r2-r3 might be 
used as "static chain pointer" what I, frankly speaking, seriously doubt ever 
to happen. I have never seen code in practice with use of the static chain 
pointer.

When using r8-r15, you might encounter problems if you are having a function 
with many many parameters. For function calls, gcc tries to pass many 
parameters in registers:

Excerpt from avr.c:
/* Allocate registers from r25 to r8 for parameters for function calls.  */

The problem is that the back-end will not be smart enough to figure out that 
your r15 might be used for a global register variable, so during a function 
call, r15 will be overwritten wether or not it's declared to be a register 
variable.

If everything else fails, you might also try to use the X register: If you are 
having fairly simple C-code, and if you are not using --mcall-prologues this 
might eventually work, if you are having much much luck. But better be 
careful and try r26-r27 only as last rescue.

HTH,

Bjoern.




reply via email to

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