|Spring 2002 Laboratory Notes: Computer Engineering II|
|Prev||Appendix B. Intel x86 Instruction Reference||Next|
BSF reg16,r/m16 ; o16 0F BC /r  BSF reg32,r/m32 ; o32 0F BC /r  BSR reg16,r/m16 ; o16 0F BD /r  BSR reg32,r/m32 ; o32 0F BD /r 
BSF searches for a set bit in its source (second) operand, starting from the bottom, and if it finds one, stores the index in its destination (first) operand. If no set bit is found, the contents of the destination operand are undefined.
BSR performs the same function, but searches from the top instead, so it finds the most significant set bit.
Bit indices are from 0 (least significant) to 15 or 31 (most significant).