void test(void)
{
struct
{
int a, b, c, d, e, f;
} x;
x.d = 5;
asm volatile("in r28, 0x2F" : : : "r28");
x.d = 6;
}
$ avr-gcc.exe -v
Using built-in specs.
Target: avr
Configured with: ../gcc-4.1.1/configure
--prefix=/c/WinAVR --target=avr
--enable-languages=c,c++ --with-dwarf2
--enable-win32-registry=WinAVR --disable-nls
--disable-libssp --disable-fixincludes
--disable-libada --with-gnu-ld --with-gnu-as
--enable-doc
Thread model: single
gcc version 4.1.1 (WinAVR 20070122)
$ avr-gcc.exe -mmcu=atmega8515 -c test.c -Wall
-gdwarf-2 -o test.o
$ avr-objdump.exe -S test.o
.
:
which compiles to:
.
:
x.d = 5;
14: 85 e0 ldi r24, 0x05 ; 5
16: 90 e0 ldi r25, 0x00 ; 0
18: 98 87 std Y+8, r25 ; 0x08
1a: 8f 83 std Y+7, r24 ; 0x07
asm volatile("in r28, 0x2F" : : : "r28");
1c: cf b5 in r28, 0x2f ; 47
x.d = 6;
1e: 86 e0 ldi r24, 0x06 ; 6
20: 90 e0 ldi r25, 0x00 ; 0
22: 98 87 std Y+8, r25 ; 0x08
24: 8f 83 std Y+7, r24 ; 0x07
.
:
As you can see at 0x22 and 0x24, Y is getting used
without being reloaded after r28 is being messed up at 0x1C.
I suspect the problem is that inline asm doesn't want you to use r28 or r29
without restoring them, and I'm fine with that, but gcc should generate some
sort of warning then, if it sees r28 or r29 in the clobber list.
--
Summary: Clobber list isn't working
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hafeliel at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32895