_BitScanReverse
Classification
Other, Bit Manipulation, CPUID Test: None
Header File
Instruction
BSR r32, r32
Synopsis
_BitScanReverse(unsigned __int32* index, unsigned __int32 a);
Description
Set "index" to the index of the highest set bit in 32-bit integer "mask". If no bits are set in "a", then "index" is undefined and "dst" is set to 0, otherwise "dst" is set to 1.
Operation
tmp := 31
IF a == 0
// MEM[index+31:index] is undefined
dst := 0
ELSE
DO WHILE ((tmp > 0) AND a[tmp] == 0)
tmp := tmp - 1
OD
MEM[index+31:index] := tmp
dst := (tmp == 0) ? 0 : 1
FI