Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: Arrays and pointers in GCC

2009-01-12 by David VanHorn

> * r1 always has the value zero
> * A function can freely modify r0,

BUT!.....

> Moreover, an ISR must preserve all register values and cannot rely on
> r1 being zero.

Maybe I'm missing something here, but what's the point of "almost
always having 0 in R1"

In ASM, I allocate a register to hold 0, but it is ALWAYS zero, and I
have a sanity check routine that looks for any non-zero values in R0,
stack other than a predefined value in main, as well as other values
that I can know in advance.


> The code that was generated for the ISR is reasonable with respect to
> these assumptions.  It is a known issue, however, that generated ISR
> code sometimes goes to the trouble of saving and zeroing r1 when it
> doesn't use r1 itself and doesn't call any external functions.

That seems like a trivial thing to fix.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.