[Top][All Lists]

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

Re: [avr-gcc-list] Mega 128 not optimising correctly ...

From: Rob Ward
Subject: Re: [avr-gcc-list] Mega 128 not optimising correctly ...
Date: Tue, 12 Nov 2002 10:50:16 +1300
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826

Hi again Eric. The good news is your typecast does produce the shorter cleaner simpler and better code. However, after removing the typecast again, it also seems to compile in exactly the same (today) as without the typecast. Should I send some example code to one of the developers?


E. Weddington wrote:
On 12 Nov 2002 at 9:29, Rob Ward wrote:

Hi Eric. I am using AVR-GCC 3.2 20020616 (experimental).

Regarding -std=gnu99 ... I am not using this switch. I have found this
info on it ... A new edition of the ISO C standard was published in
1999 as ISO/IEC 9899:1999, and is commonly known as C99. GCC has
incomplete support for this standard version;
seehttp://gcc.gnu.org/c99status.htmlfor details. To select this
standard, use `-std=c99' or `- std=iso9899:1999'. (While in
development, drafts of this standard version were referred to asC9X.)
Regards, Rob


Ok, it's the same version. If you don't want to use the same -std 
switch then, I have one other suggestion.

It was brought up that in Standard C most operators promote chars to 
ints. This could produce non-optimal code. Try typecasting the 
operations to unsigned char and see if that will clean up the code. 
The bit-wise NOT is especially known to do this. So try something 
like this:

#define SetClockHigh() ((unsigned char)PORTD |= (unsigned char)0x80) 
// set clock line high

#define SetClockLow() ((unsigned char)PORTD &= (unsigned char)~0x80) 
// set clock line low
// Note the placement of typecast before the bit-wise NOT.

Note, that I haven't tried this, as I don't get the same problem.



Thanks in advance.

Rob Ward
Beaglehole Instruments Ltd.,
32 Salamanca Road,
New Zealand.
Phone +64 4 473 7749
Fax +64 4 473 2686

avr-gcc-list at http://avr1.org
reply via email to

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