09-10-2014 10:41 AM
Do not Add and Subtract when it comes to Boolean logic. AND and OR are what you want. If the bit comes in as a TRUE, you OR your number with 1 where that bit belongs (1 OR 1 = 1). If the bit comes in as a FALSE, you AND that bit as a 0.
So let's just say you have 0xFFFF right now. You are told to endable bit 5. So you perform 0xFFFF OR 0x0010 = 0xFFFF. Yep, that test is still enabled.
Now you are told to disable bit 5. So you perform 0xFFFF AND 0xFFEF = 0xFFEF. Or if you had nothing enabled before, you have 0x0000 AND 0xFFEF = 0x0000. Yep, still not running anything.
09-15-2014 07:42 AM
thanks