This inline function uses a single assembly instructions to perform the following while loop. The bit number of the most significant bit set in
mask is determined.
unsigned int msbNum = 0 ;
unsigned int bitScan = 0x1 << 31 ;
while (bitScan != 0)
if ( (bitScan & mask) != 0)
bitScan >>= 1 ;
return msbNum ;
|mask ||Bit field whose most significant non-zero bit will be reported. |
- Bit number of most significant 1 bit in
mask where the MS bit is bit number zero and LS bit is bit number 31. If
mask is zero the return value will be 32.
- This function is not available in the SC1x, SC2x and SC1x3 C-Library.
- SC2x3 n/a - CLIB V1.00