Machine Instruction · Computer Organization and Architecture
36 questions · asked in 19 of 27 years (2000–2026)
MCQ 27 · MSQ 1 · NAT 81-mark 22 · 2-mark 14
2000Questions per year2026
Questions 31–35 of 36
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.
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?
MOV B, # 0 ; B ← 0
MOV C, # 8 ; C ← 8
Z : CMP C, # 0 ; compare C with 0
JZX ; jump to X if zero flag is set
SUB C, # 1 ; C ← 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
; 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 set
JMP Z ; jump to Z
Y : ADD B, # 1 ; B ← B + 1
JMP Z ; jump to Z
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?
Answer: (A)
C starts at 8 and falls by 1 in each pass, so the loop does exactly 8 instructions before the jump to X. Treat A and the carry as one 9-bit ring that rotates right by one bit per . Take the carry flag as changed only by .
- Start: , carry .
- After 1 rotation: , carry .
- After 2 rotations: , carry .
- After 8 rotations: , carry .
A ring of 9 bits returns to its start after 9 rotations, so one more at X gives back , the original value.
(B) NOP leaves A as , which is not the original in general.
(C) A left rotate through carry gives , which is a 2-place shift of the ring from the original, so it is not the original in general.
(D) adds 1 to the rotated value, which cannot restore the original bits.
Answer: (A)
- Start: , carry .
- After 1 rotation: , carry .
- After 2 rotations: , carry .
- After 8 rotations: , carry .
A ring of 9 bits returns to its start after 9 rotations, so one more at X gives back , the original value.
(B) NOP leaves A as , which is not the original in general.
(C) A left rotate through carry gives , which is a 2-place shift of the ring from the original, so it is not the original in general.
(D) adds 1 to the rotated value, which cannot restore the original bits.
Answer: (A)
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.
If the initial value of register A is A0 the value of register B after the program execution will be
MOV B, # 0 ; B ← 0
MOV C, # 8 ; C ← 8
Z : CMP C, # 0 ; compare C with 0
JZX ; jump to X if zero flag is set
SUB C, # 1 ; C ← 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
; 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 set
JMP Z ; jump to Z
Y : ADD B, # 1 ; B ← B + 1
JMP Z ; jump to Z
X : If the initial value of register A is A0 the value of register B after the program execution will be
Answer: (B)
starts at 0 and starts at 8. In each pass, checks whether is 0; if so the program jumps to X and ends. Otherwise goes down by 1 and rotates A right through the carry. The bit that leaves A, on the first pass, then , and so on, goes into the carry.
- If that bit is 1, the carry is set, is taken and goes up by 1.
- If that bit is 0, the program jumps back to Z and stays the same.
C takes the values 8, 7, ..., 1, so the loop runs exactly 8 times. In these 8 passes each of the 8 bits of goes through the carry exactly once. So counts the 1 bits of .
(A) is wrong because 0 bits do not increase . (D) would hold only when every bit is 1. (C) is wrong because is a count from 0 to 8, not the value of .
Answer: (B)
- If that bit is 1, the carry is set, is taken and goes up by 1.
- If that bit is 0, the program jumps back to Z and stays the same.
C takes the values 8, 7, ..., 1, so the loop runs exactly 8 times. In these 8 passes each of the 8 bits of goes through the carry exactly once. So counts the 1 bits of .
(A) is wrong because 0 bits do not increase . (D) would hold only when every bit is 1. (C) is wrong because is a count from 0 to 8, not the value of .
Answer: (B)
What are the states of the Auxiliary Carry (AC) and Carry Flag (CY) after executing the following 8085 program ?
MVI H, 5DH
MVI L, 6BH
MOV A, H
ADD L
MVI H, 5DH
MVI L, 6BH
MOV A, H
ADD L
Answer: (C)
H is loaded with 5DH and L with 6BH. Then H is copied into A, and L is added to A.
Add the two numbers:
- Lower nibble: . The value is above 15, so a carry goes from bit 3 to bit 4. So AC = 1.
- Upper nibble: . It fits in 4 bits, so no carry comes out of bit 7. So CY = 0.
The result is A = C8H, with AC = 1 and CY = 0.
Answer: (C)In 8085 which of the following modifies the program counter ?
Answer: (D)
Every instruction changes the PC. PCHL copies the content of the HL pair into the PC. CALL and JMP change the PC to the address they jump to. When ADD is executed, the PC is incremented so the next instruction can be fetched.
Suppose a processor does not have any stack pointer register. Which of the following statements is true ?
Answer: (B)
A call has to save the return address, and the return instruction uses it to come back. Without a stack pointer, there is still a way to do this for one call: keep the return address in a fixed register or a fixed memory location (as a link register does). So a subroutine call instruction can exist, and (A) is wrong.
With nested calls, a second call is made before the first returns. It would write its return address into the same place and overwrite the first one, so the first subroutine could not return to its caller. A stack is what keeps many return addresses in order, so nested calls need one. So (B) is right.
(C) is wrong because nested calls are not possible. (D) is wrong for the same reason.
Answer: (B)
With nested calls, a second call is made before the first returns. It would write its return address into the same place and overwrite the first one, so the first subroutine could not return to its caller. A stack is what keeps many return addresses in order, so nested calls need one. So (B) is right.
(C) is wrong because nested calls are not possible. (D) is wrong for the same reason.
Answer: (B)
Keep practising