[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] efficiency of assigning bits
From: |
David Willmore |
Subject: |
Re: [avr-gcc-list] efficiency of assigning bits |
Date: |
Mon, 14 Mar 2005 14:23:59 -0500 |
> >PORTD = (PORTD & ~PD1) & ~PD4;
> >
> >or:
> >
> >cbi(PORTD, PD1);
> >cbi(PORTD, PD4);
> >I am assuming these are equivalent.
>
> Not quite. Do this:
>
> PORTD &= ~(_BV(PD1) | _BV(PD4));
>
> That will clear the two bits at the same time.
Hello, all. I'm a bit confused by many of the comments in this
thread. Where is there a guarentee that the two bits will be
set at the same time in any of the shown examples?
If I understand correctly, any of:
PORTD &= ~_BV(PD1);
PORTD &= ~_BV(PD4);
or
PORTD &= ~(_BV(PD1) | _BV(PD4));
or other variants are completely the same in what kind of code
they may generate when it gets down to machine language, no?
There is no implied simultinaity in any of these statements--
all C offers you is that the user code won't be able to tell
the difference--unless PORTD is defined as a volatile. Which
may be the default and would explain my confusion.
Is that the critical bit that I'm missing?
Cheers,
David
- [avr-gcc-list] efficiency of assigning bits, Jamie Morken, 2005/03/13
- Re: [avr-gcc-list] efficiency of assigning bits, E. Weddington, 2005/03/14
- Re: [avr-gcc-list] efficiency of assigning bits,
David Willmore <=
- Re: [avr-gcc-list] efficiency of assigning bits, E. Weddington, 2005/03/14
- Re: [avr-gcc-list] efficiency of assigning bits, Erik Walthinsen, 2005/03/14
- Re: [avr-gcc-list] efficiency of assigning bits, Jesper Hansen, 2005/03/14
- Re: [avr-gcc-list] efficiency of assigning bits, E. Weddington, 2005/03/14
- Re: [avr-gcc-list] efficiency of assigning bits, Erik Walthinsen, 2005/03/14
- Re: [avr-gcc-list] efficiency of assigning bits (OT), Hugo González Monteverde, 2005/03/15
- Re: [avr-gcc-list] efficiency of assigning bits, Dave Hansen, 2005/03/14
- Re: [avr-gcc-list] efficiency of assigning bits, Christof Krueger, 2005/03/14
Fwd: Re: [avr-gcc-list] efficiency of assigning bits, Royce & Sharal Pereira, 2005/03/14