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

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

[avr-gcc-list] Horrible code


From: James L. Evans
Subject: [avr-gcc-list] Horrible code
Date: Tue, 16 May 2006 18:47:11 -0400

Could someone with a 4.1 version of the AVR-GCC compiler please compile
the following code (-Os) and see if it generates better code than the
horrible code (25 instructions) generated for Case 2 by version 3.4.3?

Thanks,

Jim Evans


#include <inttypes.h>
#include <avr/io.h>

void test7(void) {
    while (PINA & 0x40) PORTA = 0;                  // Case 1

    while ((PINA & 0x40) == 0) PORTA = 0;           // Case 2

    while (!(PINA & 0x40)) PORTA = 0;               // Case 3

    uint8_t b;
    while ((b = (PINA & 0x40)) == 0) PORTA = 0;     // Case 4
}




reply via email to

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