Hi David >@2009.04.22_12:48:52_+0200
<snip> > However, based on your other post in this thread, you are correct in > that volatile access is not what you need - it's atomic access (that > applies to 8-bit data as well as 32-bit data). > I need to make it very clear to all concerned that I am painfully aware of the issues and differences between atomicity and volatile. I also want to move the discussion on because this is about optimisation. I compile this code: (note no volatile, same source, same compiler options) uint32_t status; static inline void set_status(uint32_t flag, uint8_t set) __attribute__((always_inline)); void set_status(uint32_t flag, uint8_t set) { if (set) status |= flag; else status &= ~flag; } If I strip down main() to this it shows the same result. void main(void) { set_status(0x00400000UL, 1); } Gave: 0000e6f2 <main>: e6f2: 80 91 f3 17 lds r24, 0x17F3 e6f6: 90 91 f4 17 lds r25, 0x17F4 e6fa: a0 91 f5 17 lds r26, 0x17F5 e6fe: b0 91 f6 17 lds r27, 0x17F6 e702: a0 64 ori r26, 0x40 ; 64 e704: 80 93 f3 17 sts 0x17F3, r24 e708: 90 93 f4 17 sts 0x17F4, r25 e70c: a0 93 f5 17 sts 0x17F5, r26 e710: b0 93 f6 17 sts 0x17F6, r27 e714: 08 95 ret Dale. _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list