Write a program that counts the number of bits equal to one in R1, and stores the result in R2. For example, if R1=x0A0C, then R2=x0004 after the program runs. To receive credit, you can only modify the contents of R1 and R2, and no other register, and your solution should have no more than 9 lines of code.

Respuesta :

Answer:

MOV R1, $0A0C    ;

  MOV R2, #0 ;

L1 : MOV R1, R1, LSL #1 ;

  ADC R2, R2, #1 ;

  CMP R1, #0 ;

  BNE L1    ;