[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] GCC problem, volatile
From: |
Andreas Becker |
Subject: |
[avr-gcc-list] GCC problem, volatile |
Date: |
Fri, 12 Mar 2004 14:48:41 +0100 |
Hi All,
I'm using AVR-GCC 3.3.2
I have got a a problem with the the optimisation the Compiler does.
The C File:
#include <stdlib.h>
#include <avr/signal.h>
#define _RX_BUFFER_SIZE 30
#define _RX_BUFFER_NUMBER 5
typedef struct
{
char buffer[_RX_BUFFER_SIZE];
char elements;
} _RX_BUFFER;
static _RX_BUFFER _rx_buffers[_RX_BUFFER_NUMBER];
static volatile _RX_BUFFER *_rx_decode_buffer;
SIGNAL(SIG_ADC)
{
_rx_decode_buffer++;
}
extern int main (void)
{
while(1)
{
if (_rx_decode_buffer != NULL)
{
_rx_decode_buffer = NULL;
}
}
}
If I use Optlevel 0 everything works fine.
ASSEMBLER CODE from the .lss File:
while(1)
{
if (_rx_decode_buffer != NULL)
d2: 80 91 fb 00 lds r24, 0x00FB
d6: 90 91 fc 00 lds r25, 0x00FC
da: 00 97 sbiw r24, 0x00 ; 0
dc: d1 f3 breq .-12 ; 0xd2
{
_rx_decode_buffer = NULL;
de: 10 92 fc 00 sts 0x00FC, r1
e2: 10 92 fb 00 sts 0x00FB, r1
e6: f5 cf rjmp .-22 ; 0xd2
If I use Optlevel 1 the Compiler does't reloads the _rx_decode_buffer
Pointer. Compare the Line 0xdc (Optlevel 0) and Line 0xce (Optlevel 1).
The Destination of the Jump is another.
ASSEMBLER CODE from the .lss File:
while(1)
c4: 80 91 fb 00 lds r24, 0x00FB
c8: 90 91 fc 00 lds r25, 0x00FC
{
if (_rx_decode_buffer != NULL)
cc: 00 97 sbiw r24, 0x00 ; 0
ce: f1 f3 breq .-4 ; 0xcc
{
_rx_decode_buffer = NULL;
d0: 80 e0 ldi r24, 0x00 ; 0
d2: 90 e0 ldi r25, 0x00 ; 0
d4: fb cf rjmp .-10 ; 0xcc
Is it my fault, or is there something wrong with the
Compiler?
--
Dipl.-Ing.(FH) Andreas Becker
Entwicklung
dSys e.K.
Soeflinger Str. 100
D-89077 Ulm
Tel: +49.731.151579-1
Fax: +49.731.151579-9
web: www.dsys.de
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list
- [avr-gcc-list] GCC problem, volatile,
Andreas Becker <=