avrdudes / avr-libc

The AVR-LibC package provides a subset of the standard C library for AVR 8-bit RISC microcontrollers.
https://avrdudes.github.io/avr-libc/
Other
261 stars 57 forks source link

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

Closed avrs-admin closed 2 years ago

avrs-admin commented 2 years ago

Sat 31 Oct 2009 09:46:15 PM CET

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 _LPMenhanced seems to modify Z, at least according to the disassembly.

include <avr/pgmspace.h>

include

void try(uint8_t p) { uint16_t addr = 0; uint8_t j; for (j = 0; j < 10; j++) { p = _LPMenhanced(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:

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

This issue was migrated from https://savannah.nongnu.org/bugs/?27893

avrs-admin commented 2 years ago

Stefan Ernst Sun 01 Nov 2009 11:16:32 AM CET

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

avrs-admin commented 2 years ago

Elrond Sun 01 Nov 2009 01:47:34 PM CET

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.

avrs-admin commented 2 years ago

Elrond Sun 15 Nov 2009 06:20:41 PM CET

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

Can someone please threat the bug here appropiately?

avrs-admin commented 2 years ago

Anitha Boyapati Tue 06 Apr 2010 01:48:16 PM CEST

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

avrs-admin commented 2 years ago

Eric Weddington Tue 06 Apr 2010 05:26:40 PM CEST

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