8/16bit oddities on avr-gcc

Sergei Organov osv@javad.com
Fri Mar 2 12:14:00 GMT 2007


"Michael Kukat" <michael@unixiron.org> writes:

> Hello,
>
> i'm programming a lot of AVR firmware since a while, first in pure
> assembler, as gcc 3.x didn't produce code i liked very much. But the
> 4.1.1 i'm currently using produces quite good code if you sometimes
> try around to get the best results (as in "i would write nearly the
> same in assembler").
>
> But now, i found one strange thing where i currently can't find a
> workaround i really like. It's about a quite simple loop here:
>
> This is my perftest.c file:
> #include <avr/io.h>
> #include < inttypes.h>
>
> volatile uint8_t xx;
>
> void test() {
>        uint8_t ctr;
>
>        ctr = 0;
>        do {
>                xx = ctr;
>        } while(++ctr < 64);

Try "while((uint8_t)(++ctr) < 64)"

-- 
Sergei.



More information about the Gcc-help mailing list