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
depending on the processor you use, did you have a look at the STLDSR instruction ? This instruction is only available on ISA_A+ and ISA_C instruction sets. For further information you can look into the Coldfire Programmer's Ref. Manual.