gnupic@linuxhacker.org

gnupic@linuxhacker.org


Subject: SDCC overoptimizing
From: Erik Gustavsson
Date: Fri, 28 Mar 2003 23:25:39 +0100 (MET)

Hi.

I've used only ASM for my previous PIC projects, but
now I thought I'd give SDCC a try for my latest creation.

I'm having some problems with statements getting optimized
down to nothing. For example:

while(!TMR1IF);

I would expect this to become something like:

label:
BTFSS TMR1IF
GOTO label

But instead it just becomes an endless loop...

Also, I'm trying to write a byte to a HD44780 LCD
using this code snippet:

#define LCD_DPORT PORTA
BIT_AT(PORTB_ADDR,4) LCD_E1;
BIT_AT(PORTB_ADDR,5) LCD_E2;
BIT_AT(PORTB_ADDR,6) LCD_RS;
BIT_AT(PORTB_ADDR,7) LCD_RW;

void lcd_write(char x)
{
   LCD_DPORT=x;
   LCD_E1=1;   
   LCD_E1=0;
}

Here the first E1 assignment (that is "BSF PORTB,4") is
optimized away...



gnupic@linuxhacker.org