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:

Which of the following instructions when inserted at location X will ensure that the value of register A after program execution is the same as its initial value?

  1. RRC A, #1

  2. NOP ; no operation

  3. LRC A, #1 ; left rotate A through carry flag by one bit

  4. ADD A, #1

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

In the end of program execution to check whether both initial and final value of register A is A0, we need to right rotate register A through carry by one bit.