Re: Mixing C and assembly with special requirements.
2012-03-29 by Don Kinzer
--- In AVR-Chat@yahoogroups.com, "Tim Mitchell" <tim@...> wrote: > And remember to save SREG in interrupt routines. Unless, of course, it isn't modified. Although usually not the case, it is possible to construct an ISR that does not modify SREG. Take, for example, this one that toggles an output on each external interrupt (assuming A.7 is set to be an output and that the device supports port bit toggling by writing to the PINx register). .global INT0_vect INT0_vect: push r24 ldi r24, 0x80 out _SFR_IO_ADDR(PINA), r24 pop r24 reti Another caveat for ISRs is that you *cannot* rely on r1 being zero in an ISR as you can in a "normal" routine. Moreover, if you call any C functions from an ISR (usually not recommended) you must set r1 to zero before calling any C function. Don Kinzer ZBasic Microcontrollers http://www.zbasic.net