[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Avr-gcc Removing Port Register Access
From: |
User Tomdean |
Subject: |
Re: [avr-gcc-list] Avr-gcc Removing Port Register Access |
Date: |
Sat, 26 Aug 2006 09:35:39 -0700 (PDT) |
Here is a reduced application that reproduces the problem. It may not
be minimal.
The compiler is
# avr-gcc --version
avr-gcc (GCC) 3.4.6
The command line is
# avr-gcc -mmcu=atmega8515 -Wall -Wmissing-prototypes \
-Os -I. -c -S sbi-test.s sbi-test.c
In sbi-test.s, the two statements,
sbi 59-0x20,6
rjmp .L9
bracket the missing sbi.
If I change to -O, the missing sbi is included.
/*
* sbi-test.c
*/
#include <avr/io.h> /* port definitions */
#include <sbi-test.h> /* local definitions */
void initialize() {
LED_DDR = 0xff; /* all out */
LED_PORT = 0xff; /* all off */
DDRC= 0; /* all input */
DDRE = 0x06;
PORTD = 0x40; /* PE[1]=0, PE[2]=1 */
OSCCAL = 0x9c; /* adjust for 8.000 mHz */
UBRRL = 12; /* 38400 at 8.000 mHz */
}
/*
* main()
*/
int main() {
char phase;
initialize();
LED_ON(7);
LED_OFF(7);
while (1) {
LED_ON(7);
LED_ON(3);
while (!BIT_WAIT) {
}
LED_OFF(3);
LED_ON(5);
PORTE |= _BV(PE1);
PORTE &= ~_BV(PE1);
PORTE &= ~_BV(PE2);
phase = PINC;
PORTE |= _BV(PE2);
LED_OFF(5);
/*
* reset the RCO2 counter
*/
PORTD &= ~_BV(4);
PORTD |= _BV(4);
LED_ON(6);
while (BIT_WAIT) ;
LED_OFF(6);
LED_OFF(7); /* this is dropped */
}
return 0;
}
/*
* sbi-test.h - Test gcc dropping sbi
*/
#ifndef _SBI_TEST_H_
#define _SBI_TEST_H_
#define LED_PORT PORTA
#define LED_DDR DDRA
#define LED_OFF(n) LED_PORT |= _BV(n)
#define LED_ON(n) LED_PORT &= ~_BV(n)
#define BIT_WAIT (PINE & _BV(PINE0))
void initialize(void);
#endif /* !_SBI_TEST_H_ */
tomdean