Page 2 of 2

Re: Bits manipulation

Posted: Sat Mar 14, 2015 3:00 pm
by XCoder
I have written two macros that will set or clear bits and I am posting them here for others to use.

Macro SetBit(MyDWord,bit) ;Bit values are 1, 2, 4, 8, 16, 32. Bits are referenced as 1,2,3...
EnableASM
mov eax, bit
Or MyDWord, eax
DisableASM
EndMacro

and :

Macro ClearBit(MyDWord,bit)
EnableASM
mov eax, bit
XOr eax, $FF
And MyDWord, eax
DisableASM
EndMacro

Both macros operate directly on the variable MyDWord; however, I don't know whether these macros are more or less efficient than the code posted previously.