Bit Scan Reverse                               

86/88

N

186

N

286

N

386

Y

486

Y

BSR destination, source

Ovfl

N

Dir

N

Int

N

Trap

N

Sign

N

Zero

Y

Aux

N

Prty

N

Carry

N

    Scans source operand for first bit set.   Sets ZF if a bit is found
    set and loads the destination with an index to first set bit.  Clears
    ZF is no bits are found set.   BSF scans forward across bit pattern
    (0-n) while BSR scans in reverse (n-0).

------------------------------------ Timing ----------------------------------

OpCode          Instruction             386     286     86
0F BD           BSR r16, r/m16          10+3n
0F BD           BSR r32, r/m32          10+3n

------------------------------------ Logic -----------------------------------

        If source = 0 then
                ZF = 0
        else
                ZF = 1
                destination = bit index of first bit set

See Also BSF BT BTC BTR BTS SETxx Flags


Copyright © 1985 to 2022 Beta Systems                            Last modified: Wednesday, January 05, 2022 .