[Top][All Lists]

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

Re: [avr-gcc-list] 2 tricky questions

From: Christian Vogel
Subject: Re: [avr-gcc-list] 2 tricky questions
Date: Wed, 18 Jun 2003 18:00:50 +0200
User-agent: Mutt/

On Tue, Jun 17, 2003 at 10:44:04PM +0800, Kang Tin LAI wrote:
> 2) Is it possible to link user defined (my) interrupt prologue and epilogue
> functions instead of the integrated ones ?

You can declare the function with the "naked" attribute.

__attribute__((naked)) SIGNAL(XXX){
        asm("...");  /* <--- your prologue */
        /* your code */
        asm("...");  /* <--- your epilogue */

Which will leave the usual prologue (push r0, in r0,0x3f, ...)
and epilogue ("..., pop r0, reti") out of the compiler-generated

*BUT*: You will have to take care of all register the
compiler might decide to use in /* your code */ and save
them to the stack... and those registers might change
whenever you install a new version of gcc for example. So one can
argue that it does not make much sense to mix a naked function
with c-code but rather write the whole routine in assembler then...

So in consequence you might even declare this function in a
external assembler-file which can be easier to maintain...


reply via email to

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