bcm-v4

[Specification

u32 Find MS Bit (u32 x)

This routine finds the most-significant bit in x.

  1. Set tmp to x
  2. Set msbit to 0
  3. If tmp & 0xFFFF000 is not zero

    1. Right shift tmp by 16
    2. Set msbit to 16
  4. If tmp & 0x0000FF00 is not zero

    1. Right shift tmp by 8
    2. Increment msbit by 4
  5. If tmp & 0x0000000C is not zero

    1. Right shift tmp by 2
    2. Increment msbit by 2
  6. If tmp & 0x00000002 is not zero

    1. Increment msbit by 1
  7. Return msbit

Exported/Archived from the wiki to HTML on 2016-10-27