[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t
From: |
Dave Hylands |
Subject: |
Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t |
Date: |
Wed, 22 Apr 2009 08:53:30 -0700 |
Hi Alex,
On Wed, Apr 22, 2009 at 5:51 AM, Alex Wenger <address@hidden> wrote:
...snip...
>>> Try the following version of set_status:
>>>
>>> void set_status(uint32_t flag, uint8_t set) {
>>> if (set) *(uint32_t* &status) |= flag;
>>> else *(uint32_t* &status) &= ~flag;
>>> asm("" : : : "memory");
>>> }
...snip...
> Why? The memory clobber does exactly what you need for using it in an
> interrupt and outside.
So what exactly does
asm("" : : : "memory");
do?
Why is it significant for use inside an interrupt handler?
I'm guessing that it prevents re-ordering, but it isn't clear to me
why reordering would be bad in this situation.
--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/
- [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, (continued)
- [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, David Brown, 2009/04/22
- Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, Dale Whitfield, 2009/04/22
- [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, David Brown, 2009/04/22
- Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, Dale Whitfield, 2009/04/22
- [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, David Brown, 2009/04/22
- Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, Graham Davies, 2009/04/22
- Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, Dale Whitfield, 2009/04/22
- Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, Graham Davies, 2009/04/22
- Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, Paulo Marques, 2009/04/22
- Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t, Alex Wenger, 2009/04/22
- Re: [avr-gcc-list] Re: Optimisation of bit set/clear in uint32_t,
Dave Hylands <=