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

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

RE: [avr-gcc-list] Question about gcc preprocessing and port/pin assignm


From: Dave Hylands
Subject: RE: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments
Date: Wed, 8 Dec 2004 13:22:20 -0800

Hi Graham,

Sorry about the previous post - finger troubles:

In your example:

> SOME_REG = (SOME_REG & 0xFE) | 0x02;

Applying the literal interpretation of not optimizing into registers, I
could see how this could become two loads/stores.

If you coded it as:

        tmp = SOME_REG;
        tmp &= 0xFE;
        tmp |= 2;
        SOME_REG = tmp;

You should get the code that you want.

> case.  Having them both enabled for a few hundred nanoseconds 
> may not be so bad either, but what if an interrupt comes along 
> between the two instruction?

If an interrupt comes along, then you could wind up with a "long" time
between the two saves, so you'd either need to disable/restore
interrupts around the whole thing if it really matters. If only one
store occurs, then the only problem you have with an interrupt coming
along is if the interrupt changes some of the bits in "SOME_REG" that
you're not using. Then the store would wipe out the changes made by the
interrupt.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/ 



reply via email to

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