[Top][All Lists]

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

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

From: Graham Davies
Subject: Re: [avr-gcc-list] efficiency of assigning bits
Date: Sat, 19 Mar 2005 15:09:25 -0500

Jim Brain wrote:

> My understanding was that C only
> promotes to integer when doing negation
> or when other operands are integer.

This is the sort of thing you should probably go back and check on before
posting here.

> I've never seen constants promoted
> to int in a normal (1<<X) mode.

This has nothing to do with what the ANSI C specification requires.  This
just indicates that the optimizer has determined that the result will be the
same whether the operands are processed as integers or at their declared
size.  By the way, the expression you give as an example contains an object
of type integer (the literal constant 1), so even by your flawed
understanding of C you should realize that C requires the promotion of X to
int in the abstract machine.  If you don't see this in the generated machine
code, it is because the optimizer is at least half-way decent.

> And, when I negate, I do:
> PORT &=(unsigned char)~ADDR_CLK;
> to cancel the promotion.

You can't "cancel" promotions.  All you can do it take the result of an
operand or expression evaluation and cast (perform an explicit conversion)
to some type.  This is what you are doing here.


reply via email to

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