avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] What Happened to the sbi() and cbi() Macros????


From: E. Weddington
Subject: Re: [avr-gcc-list] What Happened to the sbi() and cbi() Macros????
Date: Mon, 31 Jan 2005 10:09:35 -0700
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

Royce & Sharal Pereira wrote:

I'm at a very junior level in this discussion, but I feel these macros
should never have existed.
|= and &= have always been the standard way. This way one does not have to
remember so many macros.

Also, I see the compiler is smart enough to optimise this statement, to
produce different code for SFRs and RAM.
Probably this was not so in the past, which prompted creation these macros.

All of this is correct.

Of course, one can always create any number of customised macros for oneself
if need be.
Yup.

Ned Konz has posted on this list a way to access SFRs as bits, nibbles,
bytes. This is a really elegant way instead of  _BV(), cbi(), etc. Why cant
this be made the standard way to access SFR bits? This is a far intuitive
way than the new macros bit_toggle() etc suggested by Erik Weddington.


First of all, it's Eric with a 'c'. Not a 'k', 'ck' or 'ch'. ;-)

Which way did Ned describe? Is it with a bit field? If so, there are several portability issues with using bitfields. Also, if you use a bit field you cannot operate on non-continguous bits simultaneously such as:
PORTA |= (_BV(0) | _BV(6));

Eric


reply via email to

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