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

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

Re: [avr-gcc-list] Now to do Tail Recursions?


From: Bob Paddock
Subject: Re: [avr-gcc-list] Now to do Tail Recursions?
Date: Mon, 30 Aug 2004 15:26:57 -0400
User-agent: Opera M2/7.54 (Win32, build 3865)


Example:

rcall hex8
ret

becomes

rjmp hex8

Wouldn't you risk corrupting your stack doing this? If the function you
did this from has an epilogue which pops some registers that where
pushed in the prologue, you would not return properly from hex8().

If there was an epilogue involved, you are correct.  I was looking
at the raw output code and GCC does generate code like:

#1
rcall hex8
ret

#2
ret
ret

#3      
mov r17,r25                     
mov r25,r17
[Someone had noted that one on the list before.]

Those where the three items I noted in one small routine.  I was able
to hand optimize the GCC code to squeeze twenty-four more bytes out of
it.  Every byte counts in a part that only has 2K to start with.




reply via email to

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