[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Interrupt prologue and epilogue
From: |
Galen Seitz |
Subject: |
Re: [avr-gcc-list] Interrupt prologue and epilogue |
Date: |
Wed, 11 Oct 2006 09:40:30 -0700 |
Simon Han <address@hidden> wrote:
> Is there any documentation about how interrupt prologue and
> epilogue are implemented? I am mainly interested in what registers
> need to be save and why. Please treat me as a person who is trying
> to implement interrupt handler by hand. :-)
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_reg_usage
> I understand that we have to save call-used registers, but I
> am not clear why r28 and r29 need to be saved. Further, why is it
> safe to not save other registers? Prologue also does the following,
> which I hope to figure out.
>
> push __zero_reg__
> push __tmp_reg__
> in __tmp_reg__,__SREG__
> push __tmp_reg__
> clr __zero_reg__
>
r1 (zero_reg) and r0 (tmp_reg) are scratch regs, so they need to be saved.
Called functions expect r1 to be zero. Status reg obviously needs to be
saved.
r29:r28 is sometimes used as a frame pointer. After reading the FAQ,
I'm not sure why it needs to be saved.
galen