|
From: | Wouter van Gulik |
Subject: | Re: [avr-libc-dev] [bug #21623] boot.h: Use the "z" register constraint |
Date: | Wed, 21 Nov 2007 09:13:15 +0100 |
User-agent: | Thunderbird 2.0.0.9 (Windows/20071031) |
Shaun Jackman schreef:
Follow-up Comment #2, bug #21623 (project avr-libc): Definitely remove r30 and r31 from the clobber. The spm instruction doesn't clobber the Z register, since it has the same value going out as coming in. If it did modify the Z register, it should be listed with a read/write constraint, as in "+z" or possibly "+&z" if it's an early clobber. Do you have a small test case for the EEPROM bug you mentioned? I've had no problem, and I'm using both gcc and avr-libc from head. I use both the EEPROM API and my flash patch with no trouble. I'm certainly not against more testing though.
The EEPROM problem arises when there are many (IIRC at least 7) 16 bit registers used and need to be saved over a call then gcc fails allocating space for the 16 bit vars. For more details look at this bug report http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31644
In your case however it is totally different. Here the spm instruction needs the Z register. The datasheets (for the Atmega324p and Atmeg8535) states that: "Once a programming operation is initiated, the address is latched and the Z-pointer can be used for other operations." So it's save to assume it's not modified.
In the EEPROM read word function Z was used as return value but it was not strictly necessary, any arbitrary 16 bit reg was ok. Somehow using Z as output of a assembler piece is causing trouble when having many local values.
HTH, Wouter
[Prev in Thread] | Current Thread | [Next in Thread] |