IA-32 Assembly Language Reference Manual

Bit Scan Forward (bsf)

bsf{wl}		r/m[16|32], reg[16|32]

Operation

(r/m = 0) 0 -> ZF (r/m [ne ] 0) 0 -> ZF

Description

bsf scans the bits, starting at bit 0, in the doubleword operand or the second word. If the bits are all zero, ZF is cleared. Otherwise, ZF is set and the bit index of the first set bit, found while scanning in the forward direction, is loaded into the destination register.

Example
bsf 4(%edi), %edx