[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Re: [Fwd: Re: [avr-chat] Mega644 bit test problem]
From: |
Robert von Knobloch |
Subject: |
[avr-gcc-list] Re: [Fwd: Re: [avr-chat] Mega644 bit test problem] |
Date: |
Fri, 08 May 2009 14:53:35 +0200 |
User-agent: |
Thunderbird 1.5.0.14 (X11/20060911) |
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: address@hidden
> Return-Path: <address@hidden>
> 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: address@hidden (Heike C. Zimmerer)
> Newsgroups: lists.avr-chat
> Subject: Re: [avr-chat] Mega644 bit test problem
> References: <address@hidden>
> 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: <address@hidden> (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 <address@hidden> 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-gcc-list] Re: [Fwd: Re: [avr-chat] Mega644 bit test problem],
Robert von Knobloch <=