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

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

[avr-gcc-list] Function prologue and epilogues of gcc


From: torsten
Subject: [avr-gcc-list] Function prologue and epilogues of gcc
Date: Fri, 21 Oct 2005 17:29:38 +0200
User-agent: Mutt/1.5.9i

Hi all, 

I am wondering about the function prologues and epilogues that avr-gcc
is generating. The following is a function epilogue of a trivial
testing function:

  90 001e 8DB7                  in r24,__SP_L__
  91 0020 9EB7                  in r25,__SP_H__
  92 0022 0896                  adiw r24,8
  93 0024 0FB6                  in __tmp_reg__,__SREG__
  94 0026 F894                  cli
  95 0028 9EBF                  out __SP_H__,r25
  96 002a 0FBE                  out __SREG__,__tmp_reg__
  97 002c 8DBF                  out __SP_L__,r24
  98                    /* epilogue: frame size=0 */
  99 002e 0895                  ret

Originally I thought it is trivial that this is needed but later on I 
was wondering. Why can't this be written as

        in r24,__SP_L__
        in r25,__SP_H__
        adiw r24,8
        out __SP_L__,r24
        out __SP_H__,r25

The worst case I could imagine is that the stack temporarily ends up
using at most 255 extra bytes which might or might not be a problem. An 
interrupt triggered in that instance should not use to much memory but I
would not expect a sane interrupt handler to waste stack space.

It would save 3 words of flash memory and a few cycles for my
application. What am I missing?

Greetings

        Torsten




reply via email to

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