bugAVR C Runtime Library - Bugs: bug #27893, pgmspace.h: __LPM_enhanced__...

 
 

bug #27893: pgmspace.h: __LPM_enhanced__ modifies Z on atmega8515

Submitted by:  Elrond <elrond>
Submitted on:  Sat 31 Oct 2009 08:46:15 PM UTC  
 
Category: HeaderSeverity: 3 - Normal
Priority: 9 - ImmediateItem Group: Header files
Status: TransferredPercent Complete: 0%
Assigned to: NoneOpen/Closed: Closed
Release: 1.6.2Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 06 Apr 2010 03:26:40 PM UTC, comment #5:

Closing this bug as "Transferred" as it was transferred to Binutils bug #10964.

Eric Weddington <arcanum>
Project Administrator
Tue 06 Apr 2010 11:48:16 AM UTC, comment #4:

Looks like the bug has been marked as 'invalid' and 'resolved' in binutils bugzilla. Is this still relevant ? Please comment.

Anitha Boyapati <aboyapati>
Sun 15 Nov 2009 05:20:41 PM UTC, comment #3:

Okay, bug filed in binutils:
http://sourceware.org/bugzilla/show_bug.cgi?id=10964

Can someone please threat the bug here appropiately?

Elrond <elrond>
Sun 01 Nov 2009 12:47:34 PM UTC, comment #2:

After a second look, my try_asm example shows the disassembler problem.

I have rebuild binutils-avr 2.20-1 for my system, but the objdump-disassemble-error persists.

Unless someone else is quicker, I will try to submit a bug to binutils sometime soon.

Elrond <elrond>
Sun 01 Nov 2009 10:16:32 AM UTC, comment #1:

It is a bug of the disassembler.
Opcode 0x9184 is actually "lpm r24, Z" (not Z+).

Stefan Ernst <sternst>
Sat 31 Oct 2009 08:46:15 PM UTC, original submission:

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:

                1. <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.

Elrond <elrond>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by aboyapati (Posted a comment)
  • -unavailable- added by arcanum (Updated the item)
  • -unavailable- added by sternst (Posted a comment)
  • -unavailable- added by elrond (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 06 Apr 2010 03:26:40 PM UTCarcanumStatusNone=>Transferred
      Open/ClosedOpen=>Closed
    Mon 29 Mar 2010 05:29:06 PM UTCarcanumPriority5 - Normal=>9 - Immediate

    Back to the top


    Powered by Savane 3.1-cleanup1