[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] [bug #27893] pgmspace.h: __LPM_enhanced__ modifies Z on a
From: |
Elrond |
Subject: |
[avr-libc-dev] [bug #27893] pgmspace.h: __LPM_enhanced__ modifies Z on atmega8515 |
Date: |
Sat, 31 Oct 2009 20:46:27 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.15) Gecko/2009102815 Iceweasel/3.0.14 (Debian-3.0.14-1) |
URL:
<http://savannah.nongnu.org/bugs/?27893>
Summary: pgmspace.h: __LPM_enhanced__ modifies Z on
atmega8515
Project: AVR C Runtime Library
Submitted by: elrond
Submitted on: Sa 31 Okt 2009 21:46:15 CET
Category: Header
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Header files
Status: None
Percent Complete: 0%
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Release: 1.6.2
Fixed Release: None
_______________________________________________________
Details:
Affected version: Debian avr-libc 1:1.6.2.cvs20080610-2
Current CVS most likely also affected, as macro didn't change.
At least on the atmega8515 __LPM_enhanced__ seems to modify Z, at least
according to the disassembly.
#include <avr/pgmspace.h>
#include <stdint.h>
void try(uint8_t *p) {
uint16_t addr = 0;
uint8_t j;
for (j = 0; j < 10; j++) {
*p = __LPM_enhanced__(addr);
p++; addr++;
}
}
void try_asm(void) {
__asm__ __volatile__(
"lpm r18, Z+nt"
"lpm r18, Znt"
::);
}
avr-gcc -Wall -mmcu=atmega8515 -Os -g -DF_CPU=3686400 -c lpm-z-mod.c -o
lpm-z-mod.o
gives:
00000000 <try>:
0: dc 01 movw r26, r24
2: e0 e0 ldi r30, 0x00 ; 0
4: f0 e0 ldi r31, 0x00 ; 0
6: 84 91 lpm r24, Z+
8: 8d 93 st X+, r24
a: 31 96 adiw r30, 0x01 ; 1
c: ea 30 cpi r30, 0x0A ; 10
e: f1 05 cpc r31, r1
10: 01 f4 brne .+0 ; 0x12 <try+0x12>
12: 08 95 ret
00000014 <try_asm>:
14: 25 91 lpm r18, Z+
16: 24 91 lpm r18, Z+
18: 08 95 ret
Note the Z+.
Also note that the Z+ can be seen as a feature. The addr++ wouldn't be needed
anymore. But providing this feature to C in a clean way doesn't look easy at
all.
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?27893>
_______________________________________________
Nachricht geschickt von/durch Savannah
http://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] [bug #27893] pgmspace.h: __LPM_enhanced__ modifies Z on atmega8515,
Elrond <=