GATEverse
← GATE CSE 2003

Q48

MCQ2 marks, −0.5

Consider the following assembly language program for a hypothetical processor A,B,A, B, and CC are 8−8-bit registers. The meanings of various instructions are shown as comments.

MOV B, #0;B←0MOV C, #8;C←8Z:CMP C, #0;compare C with 0JZ X;jump to X if zero flag is setSUB C, #1;C←C−1RRC 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;c0 respectively, their values after the execution of this;instruction will be c0a7…a1 and a0 respectively.JC Y;jump to Y if carry flag is setJMP Z;jump to ZY:ADD B, #1;B←B+1JMP Z;jump to ZX:;\small \begin{array}{lllll} & \text{MOV B, \#0} & & \text{;} & B \leftarrow 0 \\ & \text{MOV C, \#8} & & \text{;} & C \leftarrow 8 \\ \text{Z:} & \text{CMP C, \#0} & & \text{;} & \text{compare C with 0} \\ & \text{JZ X} & & \text{;} & \text{jump to X if zero flag is set} \\ & \text{SUB C, \#1} & & \text{;} & C \leftarrow C-1 \\ & \text{RRC A, \#1} & & \text{;} & \text{right rotate A through carry by one bit. Thus:} \\ & & & \text{;} & \text{If the initial values of A and the carry flag are } a_7\dots a_0 \text{ and} \\ & & & \text{;} & c_0 \text{ respectively, their values after the execution of this} \\ & & & \text{;} & \text{instruction will be } c_0a_7\dots a_1 \text{ and } a_0 \text{ respectively.} \\ & \text{JC Y} & & \text{;} & \text{jump to Y if carry flag is set} \\ & \text{JMP Z} & & \text{;} & \text{jump to Z} \\ \text{Y:} & \text{ADD B, \#1} & & \text{;} & B \leftarrow B+1 \\ & \text{JMP Z} & & \text{;} & \text{jump to Z} \\ \text{X:} & & & \text{;} & \end{array}

If the initial value of register A is A0 the value of register B after the program execution will be

Sign in to save attempts.

Loading…