Heike C. Zimmerer wrote:
> Robert,
>
> my answer didn't make it to the avr-chat list for reasons I don't know and I 
> have no time to care about.
> Here it is again, in direct email:
>
> -------- Original-Nachricht --------
> Delivered-To: h...@hczim.de
> Return-Path: <li...@hczim.de>
> Received: from localhost (localhost [127.0.0.1])  (uid 1000)  by minni with 
> local; Fri, 08 May 2009 13:01:05 +0200  id 0061A00D.4A0410F1.00001EF1
> From: li...@hczim.de (Heike C. Zimmerer)
> Newsgroups: lists.avr-chat
> Subject: Re: [avr-chat] Mega644 bit test problem
> References: <4a03fe30.6030...@engelking.de>
> Date: Fri, 08 May 2009 13:01:03 +0200
> Organization: Mostly Harmless
> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)
> In-Reply-To: <4a03fe30.6030...@engelking.de> (Robert von Knobloch's message 
> of        "Fri, 08 May 2009 11:41:04 +0200")
> Cancel-Lock: sha1:pkIw4CMV/nyYeqt/h1Q2vNWhIwc=
> Posted-To: lists.avr-chat
> To: undisclosed-recipients: ;
>
> The following message is a courtesy copy of an article
> that has been posted to lists.avr-chat as well.
>
> Robert von Knobloch <b...@engelking.de> writes:
>
>   
>> #define ASYNCCLK    0
>> [....]
>>         while ((ASYNCPIN & _BV(ASYNCCLK)) != 1)        // Wait for clock
>> high
>> [...]
>>     
>
>   
>> This works fine. I want, however to use portb bits 1 & 3 for clock &
>> data. I simply change to #define ASYNCCLK    1
>> and re-compile
>> Now, nothing works and the code generated is much smaller (0xe5 bytes
>> instead of 0x193 bytes for the working variant).
>>     
>
> If you change ASYNCCLK away from bit 0, the above while expression will
> never yield true since you compare directly against the value of bit 0.
> So the compiler is free to remove it entirely.  The fault is the '1' on
> the right side (instead of using the actual bit value or comparing
> against 0).
>
> Heike
>
>
>   
It is so obvious that I couldn't see it (usually I compare to '0').
Thanks a lot, Heike.
Robert


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to