register variable is clobbered by passing parameter to a function

Wolfgang Kuehn wolfgang.kuehn@kristensen.de
Tue Mar 16 14:18:00 GMT 2004


> > Wolfgang, your best bet is probably to just add -fixed-r16 to your
> >compile-time flags.  And don't call any library functions that were
compiled
> >without it.

-ffixed-r16 has no effect at passing.

>> This is AVR, and he is trying to use r16.  According to
>> function_arg_regno_p() in avr.c, that register can be used to
> >pass parameters to functions.  gcc can't handle declaring a
>> register used for parameter passing as fixed.

>Ah.  Then my advice should have been "Change r16 to some safer register."
>Hopefully that should then suffice to make his global-register-var work
>correctly and there isn't actually a bug in gcc.

  Some safer register are r4,r5 and r6. And there is no effect by passing
parameters. But the register r16 (and all other above this) are more
efficient, because you can load only these immediately (ldi r16,0x10) ,
set/reset bits (sbr r17,1) and other very effective instructions.
Its a pity not to exhaust the complete power of this little processor.

In moment the best workaround for my application is not to pass more than
four (char) parameters to a function, so I am free to use the powerful
r16-register.

>The best bet might be to add a bit more
>documentation to the register-vars pages, indicating that registers chosen
>should not be call-used or fixed-for-other-purposes-by-the-abi.

Thats very welcome.

Last question: what means ABI ?

best regards
wolfgang



More information about the Gcc mailing list