Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- iAPx86 - <b>bsr bit scan reverse flags: o d i t s z a p c</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
BSR             Bit Scan Reverse                     Flags: O D I T S Z A P C
                                                            ? - - - ? * ? ? ?
BSR 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
                endif

    BSR scans (starting with MSB) 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.

        Example:        mov     dx,0110b
                        bsf     cx,dx   ; zf = 0, cx = 1
                        bsr     cx,dx   ; zf = 0, cx = 2

    Note
    Some sources wrongly state different result flags.


    Opcode      Format
    0F BD       BSR  r16,r/m16
    0F BD       BSR  r32,r/m32


    Length and timing
    Operands    Bytes   8088    186     286     386     486     Pentium
    r16, r16     3                             10+3n    6-103  7-39  NP
    r32, r32     3                             10+3n    7-104  7-71  NP
    r16, m16  3+d(0,1,2)                       10+3n    6-103  7-40  NP
    r32, m32  3+d(0,1,2,4)                     10+3n    7-104  7-72  NP

See Also: BSF TEST SHR

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson