Write a code to count the no. of 1s in a binary representation of a number?

Submitted by: Administrator
I am writing for Microcontrollers. ldi r16,$F0 ldi r17,$08 ldi r18,$00 ldi r19,$00 loop: rol r16 back: brcs one inc r19 dec r17 brne loop end:rjmp end one:inc r18 rjmp back

int count1s =0; while(num != 0){ if(num & 1 == 1){ count1s++; } num= num>>1; } printf("%d", count1s);
Submitted by: Administrator

Read Online Hardware and Software Design Job Interview Questions And Answers