|
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:
More to the point, there's a slight parentheses bug in the line that is written above. It should be this:Royce & Sharal Pereira wrote:1. What you wrote above is different than what was written above. Follow the parentheses carefully to understand why.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));
PORTD = (PORTD & (unsigned char)~(_BV(0))) | (unsigned char)_BV(1)|_BV(2)|_BV(3);
[Prev in Thread] | Current Thread | [Next in Thread] |