15.2.3 Coding ISRs

The following prototype declares function isr0 to be an interrupt handler:

void __attribute__((interrupt(auto_psv))) isr0(void);

As this prototype indicates, interrupt functions must not take parameters nor may they return a value. The compiler arranges for all working registers to be preserved, as well as the Status register and the Repeat Count register, if necessary. Other variables may be saved by naming them as parameters of the interrupt attribute. For example, to have the compiler automatically save and restore the variables, var1 and var2, use the following prototype:

void __attribute__((interrupt(auto_psv, save(var1, var2)))) isr0(void);

To request the compiler to use the fast context save (using the push.s and pop.s instructions), tag the function with the shadow attribute (see 14.1.1 Function Specifiers”). For example:

void __attribute__((interrupt(auto_psv, shadow))) isr0(void);