[Q] avr-gcc and calling convention

Hi

I am start r2-r17 are callee saved r18-27 are caller saved r25-r8 are the parameters left to right

Does this mean, I must preserve the parameter values in r17-r8 ?

TIA

--
42Bastian
Do not email to bastian42@yahoo.com, it's a spam-only account :-)
Use @epost.de instead !
Reply to
42Bastian Schick
Loading thread data ...

"42Bastian Schick" skrev i meddelandet news: snipped-for-privacy@news.individual.de...

One range is free to use by the subroutine without saving. The other needs to be pushed/popped by the subroutine to allow usage "callee" is the subroutine, and "caller" is the code calling the subroutine.

I think it works like this: if A calls B, and A wants to make sure that R18 is not changed by the call, A, needs to push R18 on the stack to make sure it is not modifíed. R18-R27 is thus free to be used by the subroutine. R2-R17 will not be modified by the subroutine.

I am not sure, since I only use IAR and occasionally Imagecraft,so if I were you I would compile a small example to find out which range is which. It may be the other way around. It would be better if the documentation said which registers can be used freely by a subroutine and which registers needs to be saved.

--
Best Regards
Ulf at atmel dot com
These comments are intended to be my own opinion and they
may, or may not be shared by my employer, Atmel Sweden.
Reply to
Ulf Samuelsson

So far, it has been clear to me. What confuses me is the overlapping set of registers r8..r17 which should be preservered in an function but may also serve as parameters.

But I guess I have to build some test functions that need a lot of registers and has a lot of parameters.

--
42Bastian
Do not email to bastian42@yahoo.com, it's a spam-only account :-)
Use @monlynx.de instead !
Reply to
42Bastian Schick

If the registers are needed as parameters, the caller knows it and so does the callee. I'd assume that the rules for parameters apply in the case where one of these registers is assigned as a parameter. Other parameters don't need to be preserved, so these probably don't either.

Reply to
Clifford Heath

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.