[Top][All Lists]

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

RE: [avr-gcc-list] 8 bit bitwise operation promoted to 16 bit values

From: Alex Shepherd
Subject: RE: [avr-gcc-list] 8 bit bitwise operation promoted to 16 bit values
Date: Mon, 27 Oct 2003 22:33:51 +1300

Hi David,


Thanks for your comments and insights, I think I understand what is
going on now. I played with the code some more today and found I was
able to make the problem go away by changing to: Mask <<= 1; in the
for(;;) loop.

> What is really needed here is an ^^ operator:
>     if ( (LN_TX_PORT & ( 0x01 << LN_TX_BIT )) ^^
>         (LN_RX_PORT & ( 0x01 << LN_RX_BIT )) ) ...

Yeah, that is what I thought too as it felt like a XOR solution was
hiding in there somewhere. I had asked a fairly knowledgeable C/C++
friend of mine, he couldn't come up with anything better. However
neither he nor I had really dealt with things this small before.

Guess I need to play around with the code and see what the compiler does
for various test cases, now you have shed some light on the underlying

Previously I had been working on a large financial model evaluation
system written in Java that initially chewed up about 2.5G of RAM on a
dual CPU DEC Alpha box, so we were happy to get it down under 1G, using
the various code optimisation tools we had.

However, all this is a far cry from saving the odd 20-30 bytes here and
there but it all adds up to fit/no-fit into a Mega8 pretty quickly.

Thanks for your explanations.



reply via email to

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