[Top][All Lists]

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

Re: [avr-gcc-list] efficiency of assigning bits

From: E. Weddington
Subject: Re: [avr-gcc-list] efficiency of assigning bits
Date: Fri, 18 Mar 2005 10:11:18 -0700
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

E. Weddington wrote:

Royce & Sharal Pereira wrote:

So would it be a good idea (for saving uC time) to convert that above line to this:

PORTD = (PORTD & (unsigned char)~(_BV(0))) | (unsigned char)_BV(1)|_BV(2)|_BV(3));

Whew! What a long winded way to do things! This takes less time/energy to enter:

PORTD &= ~(1 | (1<<1) | (1<<2));

1. What you wrote above is different than what was written above. Follow the parentheses carefully to understand why.

More to the point, there's a slight parentheses bug in the line that is written above. It should be this:

PORTD = (PORTD & (unsigned char)~(_BV(0))) | (unsigned char)_BV(1)|_BV(2)|_BV(3);

reply via email to

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