Brandon Taylor

Atomic Read/Write of SR

Discussion created by Brandon Taylor on Aug 12, 2008
Latest reply on Aug 13, 2008 by stzari
What is the best way to perform the following operations in an atomic manner: ?

- Read current value for SR[I] and retain it so that it can be restored later
- Set SR[I] to some specified value

Note that I do not wish to change any of the SR bits other than those associated with SR[I].

I am hoping that there is an easier way to do this than to:
- Call STRLDSR with a value of 0x2700 (thus disabling interrupts)
- Pop the SR that STRLDSR pushed on to the stack
- Modify bits 8-10 of the popped value to match the desired SR[I]
- Set SR to the modified value