/* If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT8 EFIAPI BitFieldCountOnes32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit)
/* If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT8 EFIAPI BitFieldCountOnes32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit)
{
  UINT32  Count;
  ASSERT (EndBit < 32);
  ASSERT (StartBit <= EndBit);
  Count  = BitFieldRead32 (Operand, StartBit, EndBit);
  Count -= ((Count >> 1) & 0x55555555);
  Count  = (Count & 0x33333333) + ((Count >> 2) & 0x33333333);
  Count += Count >> 4;
  Count &= 0x0F0F0F0F;
  Count += Count >> 8;
  Count += Count >> 16;
  return (UINT8)Count & 0x3F;
}