hey guys!
After somedays trying to use BT and BTS instructions, the result was bad.
I really cant understand how this works :(
can ayone help me with something like: "BT and BTS for dummies :U"?
greetings!
mstrcool,
Just show us what you are trying to test and I am sure someone can help you.
BT (Bit Test) sets the carry flag based on the state (0/1) of the bit being tested...
mov EAX, 4 // set the third bit
BT EAX,2 // Remember to count bits starting at 0 so the third bit is index 2
JNC >>
// Bit 2 is 1 so the carry flag is set to 1
PrintText("The bit is set")
:
BTS (Bit Test and Set) sets the carry flag in the same way as BT but on exit it will set the bit you are checking to 1
mov EAX, 0 // reset all bits
BTS EAX, 2 // check any bit
JC >>
// Bit 2 is 0 so the carry flag is set to 0
PrintText("The bit is not set")
:
// Bit 2 has been set so a check will show it is now 1
BT EAX, 2 // check any bit
JNC >>
PrintText("The bit is set")
:
Interesting things to do with it. Saturate EAX with a single bit...
mov EAX, 4
BT EAX,2
SALC
MOVSX EAX,AL