x86 Assembly Language Reference Manual

Bit Scan Reverse (bsr)

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

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

Description

bsr scans the bits, starting at the most significant bit, 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 reverse direction, is loaded into the destination register

Example
bsr 4(%edi), %edx