Multiple choice

Consider the following assembly language program for a hypothetical processor A, B, and C are 8 bit registers. The meanings of various instructions are shown as comments. MOV B, #0 ; B $\leftarrow$ 0 MOV C, #8 ; C $\leftarrow$ 8 Z: CMP C, #0 ; Compare C with 0 JZX ; Jump to X if zero flag is set SUB C, #1 ; C $\leftarrow$ C - 1 RRC A, #1 ; right rotate A through carry by one bit. Thus: ; if the initial values of A and the carry flag are a7… a0 and ; instruction will be c0a7…a1 and a0 respectively JCY ; jump to Y if carry flag is set JMP Z ; jump to Z Y: ADD B, #1 ; B $\leftarrow$ B + 1 X: If the initial value of register A is A0, the value of register B after the program execution will be

  1. the number of 0 bits in A0

  2. the number of 1 bits in A0

  3. A0

  4. 8

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Here value of B is incremented by 1 only if carry flag is 1, carry is filled using right rotation, so B will store the no. of 1s in A0.