Count Error Flags in Status Word
Write a C function to count the number of set error flags in a 32-bit status register. Only bits defined in mask should be counted.
Constraints
- Function prototype: int count_errors(uint32_t reg, uint32_t mask).
- Count only masked bits.
- Use bitwise ops.
- Return integer count.
1#include <stdint.h>2int count_errors(uint32_t reg, uint32_t mask);