@instruction<EOL><INDENT>def BSR(cpu, dest, src):<DEDENT>
value = src.read()<EOL>flag = Operators.EXTRACT(value, src.size - <NUM_LIT:1>, <NUM_LIT:1>) == <NUM_LIT:1><EOL>res = <NUM_LIT:0><EOL>for pos in reversed(range(<NUM_LIT:0>, src.size)):<EOL><INDENT>res = Operators.ITEBV(dest.size, flag, res, pos)<EOL>flag = Operators.OR(flag, (Operators.EXTRACT(value, pos, <NUM_LIT:1>) == <NUM_LIT:1>))<EOL><DEDENT>cpu.PF = cpu._calculate_parity_flag(res)<EOL>cpu.ZF = value == <NUM_LIT:0><EOL>dest.write(Operators.ITEBV(dest.size, cpu.ZF, dest.read(), res))<EOL>
Bit scan reverse.

Searches the source operand (second operand) for the most significant
set bit (1 bit). If a most significant 1 bit is found, its bit index is
stored in the destination operand (first operand). The source operand
can be a register or a memory location; the destination operand is a register.
The bit index is an unsigned offset from bit 0 of the source operand.
If the contents source operand are 0, the contents of the destination
operand is undefined::

        IF SRC  =  0
        THEN
            ZF  =  1;
            DEST is undefined;
        ELSE
            ZF  =  0;
            temp  =  OperandSize - 1;
            WHILE Bit(SRC, temp)  =  0
            DO
                temp  =  temp - 1;
                DEST  =  temp;
            OD;
        FI;

:param cpu: current CPU.
:param dest: destination operand.
:param src: source operand.