28. Bit Field Operations-i

Question.3

A developer writes a generic function to extract a bit field of any width (1 to 31) from any position in a 32-bit register:

uint32_t extract(uint32_t reg, uint8_t pos, uint8_t len) {
   uint32_t mask = ___;
   return (reg >> pos) & mask;
}

Which expression correctly generates a mask with len consecutive 1-bits?

Need Help? Refer to the Quick Guide below

Select Answer