bsr

386 and later

Bit Scan Reverse

bsr reg16, r/m16 | bsr reg32, r/m32 | bsr reg64, r/m64
  • BSF searches for the least significant set bit in its source (second) operand, 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. If the source operand is zero, the zero flag is set.

  • 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). The destination operand can only be a register. The source operand can be a register or a memory location.

Loading...

Forms

Every form of bsr the assembler accepts, from NASM's own instruction table. The second column is the processor that introduced the form; a badge marks a form that needs an extension, that is lockable, or that long mode dropped.

FormSinceNotes
bsr reg16, r/m16386
bsr reg32, r/m32386
bsr reg64, r/m64x86-64long