avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Tiny88 C++ code optimized out of existence?


From: Paulo Marques
Subject: Re: [avr-gcc-list] Tiny88 C++ code optimized out of existence?
Date: Wed, 14 Jan 2009 17:59:38 +0000
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

Bob Paddock wrote:
> I'm trying to bring up a new board that uses a Tiny88.
> I'm compiling the code as C++ code, using WinAVR 20081205/4.3.2,
> using -Os.  Makefile was produced by MFile.
> 
> This is the test program, main.cpp:
> 
> [...]
>   for(;;)
>     {
>       uint8_t byte_u8 = LED2H; // Start LED

You're initializing the variable inside the loop.

>       // Charge pump off:
>       byte_u8 |= VpumpH;
>       byte_u8 &= (uint8_t) ~VpumpL;
> 
>       PORTB = byte_u8;

Which means that when the code reaches this point, it has always the
same value in it.

>       byte_u8 <<= 1;  // Key to failing seems to be this line
>                       // without this the produced code would be
>                       // what the compiler is really generating
> 
>       //  When All LEDs have been lit, start over:
>       if( 0 == (byte_u8 & (uint8_t) ~VpumpH))
>         {
>           byte_u8 = (uint8_t) LED0H;
>         }
>     }
> }

This whole loop simplifies to:

for (;;)
       PORTB = (LED2H | VpumpH) & ~VpumpL;

I hope this helps,

-- 
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com

"Who is general Failure and why is he reading my disk?"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]