On Thu, Aug 23, 2012 at 12:49 PM, William Swanson <swanson...@gmail.com> wrote:
>> Another option is a single inline assembly call for the "|=" if the above
>> code split does not help.
>
> I've had to do this in a few places, like when I need to atomically
> update a hardware flag.

I just realized something horrible. Code like this is not safe:

  P1IFG &= ~P1_PWR_SW;

There is no assurance that the "&=" operator will work atomically.
Even if it does compile to the correct "bis.b" instruction, what
happens if another IO pin toggles mid-instruction? Could the
transition be lost? Hopefully the chip designers accounted for this,
but it's still a scary thought.

-William

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to