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

View: New views
4 Messages — Rating Filter:   Alert me  

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

by anonymous-98 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

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

by anonymous-98 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #1, bug #27893 (project avr-libc):

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


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27893>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

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

by anonymous-98 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #2, bug #27893 (project avr-libc):

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.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27893>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

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

by anonymous-98 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #3, bug #27893 (project avr-libc):

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

Can someone please threat the bug here appropiately?

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?27893>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev