[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Posible bug in avr-gcc-4.0.2 (inline asm)
From: |
Anatoly Sokolov |
Subject: |
[avr-gcc-list] Posible bug in avr-gcc-4.0.2 (inline asm) |
Date: |
Wed, 5 Oct 2005 21:24:22 +0400 |
Hello.
Studying avr-libc bug #14486 I have written the following test case.
#define SFR (*(unsigned char *)(0x80))
#define foo() \
({ \
__asm__ __volatile__ \
( \
"sts %0, 0x00\n\t" \
: "=m" (SFR) \
); \
})
int main (void)
{
foo ();
foo ();
}
The avr-gcc version 4.0.2 with optimisation (-O3 or -Os ) generates a
following code:
...
.LM2:
ldi r30,lo8(128)
ldi r31,hi8(128)
/* #APP */
sts Z, 0x00
.LM3:
sts Z, 0x00
/* #NOAPP */
....
It is not true, pointer register cannot be the first operand of sts
instruction, only constant.
If to leave only one foo in main:
int main (void)
{
foo ();
//foo ();
}
The correct code is generated;
...
.LM2:
/* #APP */
sts 128, 0x00
/* #NOAPP */
...
If to compile without optimization, again a mistake:
int main (void)
{
foo ();
//foo ();
}
...
.LM2:
ldi r30,lo8(128)
ldi r31,hi8(128)
/* #APP */
sts Z, 0x00
/* #NOAPP */
...
The avr-gcc version 3.4.4 with and without optimisation generates a correct
code:
...
.LBB2:
.LM2:
/* #APP */
sts 128, 0x00
/* #NOAPP */
.LBE2:
.LBB3:
.LM3:
/* #APP */
sts 128, 0x00
/* #NOAPP */
...
It is a bug in the avr-gcc or it is erroneous to use "m" parameter with the
sts instruction?
Anatoly.
- [avr-gcc-list] Posible bug in avr-gcc-4.0.2 (inline asm),
Anatoly Sokolov <=