|
From: | David Brown |
Subject: | Re: [avr-gcc-list] Save RAMPZ register in interrupt handler routines |
Date: | Wed, 30 Jan 2008 11:16:39 +0100 |
User-agent: | Thunderbird 2.0.0.9 (Windows/20071031) |
Anatoly Sokolov wrote:
Hi. From: "David Brown" <address@hidden> Sent: Sunday, January 27, 2008 10:57 PMI'd imagine that the use of pgm_read_*_far macros within interrupt functions is pretty rare - perhaps the best idea is to use the patch, but make "-mno-save-rampz" the default?Rare for 128K devices, but are more required for 256K devices. Also, as the Dmitry wrote, some instructions ('LD R,Z+') can change the RAMPZ register. I consider that by default saving of the RAMPZ register in interrupt handler routines should be enabled.
You've convinced me. I didn't know about the side effects of the "LD R,Z+" instruction, which changes the balance. Users may be aware that their code uses LPM instructions, and thus choose the -msave-rampz flag, but the compiler could use "LD R, Z+" and similar instructions in many situations. Generating correct code is the most important function - optimising that code is much lower priority.
Or is there some practical way to let the interrupt function save rampz if and only if it is used (or if a function is called), just like the volatile registers?With this patch avr-gcc should save the RAMPZ register, only if the Z register (r30:31) is used in interrupt handler routine.
That sounds fair enough. This way, smaller interrupt routines are unaffected, while larger routines will be made safer. It can't get much better than that!
mvh., David
Anatoly.
[Prev in Thread] | Current Thread | [Next in Thread] |