39. Bitwise Rotation and Counting-II

Question.7

A developer performs a sequence of operations on an 8-bit register that initially holds 0x35:

// Step 1: Rotate left by 2
reg = ((reg << 2) | (reg >> 6)) & 0xFF;

// Step 2: Count set bits
int count = 0;
uint8_t temp = reg;
while (temp) {
   temp &= (temp - 1);
   count++;
}

What are the values of reg and count after both steps?

Need Help? Refer to the Quick Guide below

Select Answer