[Top][All Lists]

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

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

From: Jim Brain
Subject: Re: [avr-gcc-list] efficiency of assigning bits
Date: Fri, 18 Mar 2005 20:47:40 -0600
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

My understanding was that C only promotes to integer when doing negation or when other operands are integer. I've never seen constants promoted to int in a normal (1<<X) mode.

I dislike _BV, as I don't think it adds enough value. My opinion, of course.

I would agree that 1<<3 is not maintainable code.  For AVR flags, I use:

(1<<TIMSK) type nomenclature

For data pins, I tend to do:

#define ADDR_CLK               (1<<PIN2)

And then code is:


I find that expressing it this way provides lots of value for portability, etc.

And, when I negate, I do:

PORT &=(unsigned char)~ADDR_CLK;

to cancel the promotion.


Jim Brain, Brain Innovations
address@hidden                                http://www.jbrain.com
Dabbling in WWW, Embedded Systems, Old CBM computers, and Good Times!

reply via email to

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