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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

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

Submitter:  Elrond <elrond>
Submitted:  Sat 31 Oct 2009 08:46:15 PM UTC
   
 
Category:  Header Severity:  3 - Normal
Priority:  9 - Immediate Item Group:  Header files
Status:  Transferred Assigned to:  None
Percent Complete:  0% Open/Closed:  Closed
Release:  1.6.2 Fixed Release:  None

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>
Group 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:
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.

Elrond <elrond>

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-04-06 arcanum StatusNone Transferred
        Open/ClosedOpen Closed
    2010-03-29 arcanum Priority5 - Normal 9 - Immediate

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code