u32 Find MS Bit (u32 x)
This routine finds the most-significant bit in x.
- Set tmp to x
- Set msbit to 0
If tmp & 0xFFFF000 is not zero
- Right shift tmp by 16
- Set msbit to 16
If tmp & 0x0000FF00 is not zero
- Right shift tmp by 8
- Increment msbit by 4
If tmp & 0x0000000C is not zero
- Right shift tmp by 2
- Increment msbit by 2
If tmp & 0x00000002 is not zero
- Increment msbit by 1
- Return msbit