BSF Bit Scan Forward Flags: O D I T S Z A P C ? - - - ? * ? ? ? BSF destination,source CPU: 386+
Logic if a set bit is found in source ZF ← 0 destination ← bit index of first set bit else ZF ← 1 destination ← ? endif
BSF scans (starting with bit 0) source for a one-bit. The zero flag (ZF) is set to 1 if the bits are all zero; otherwise, ZF is cleared to 0 and destination is loaded with the bit index of the first set bit.