Question: The following C code counts the number of 1 bits in u8_j and returns the answer in u8_k. Convert this to PIC24 assembly code. You
The following C code counts the number of 1 bits in u8_j and returns the answer in u8_k. Convert this to PIC24 assembly code. You may want to convert the for loop structure to a while loop structure.
uint8_t u8_i,u8_j,u8_k; u8_k = 0; // init bit count
for (u8_i = 0; u8_i != 8; u8_i++) { // do for 8 bits
if ((u8_j & 0x01) == 1) {
u8_k++; // LSb = 1, increment count
}
u8_j = u8_j >> 1; // look at the next bit
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
