GATE / CS ARCHIVE

GATE CSE 1993 / QUESTION 20(b)

Register and address roles

Computer Organization & Architecture · Instructions & Addressing Modes · Full GATE CSE 1993 paper

GATE 1993, Q20(b) Descriptive
Report issue

Instructions & Addressing Modes

Question 20(b), GATE 1993: List the registers and addressed locations used by: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Question 20(b), GATE 1993: List the registers and addressed locations used by: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Question 20(b), GATE 1993: List the registers and addressed locations used by: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Tap to enlarge
Answer & solution

Answer: HL destination pointer; B count; A input byte; cells 5000/5001 hold pointer; 20 is input-port address; GET is a code label. (no official key was published)

L and H jointly form a 16-bit destination pointer, with L the low byte. LHLD fetches its initial low and high bytes from consecutive memory cells 5000 and 5001; it does not set HL to the literal 5000. The symbol M in MOV M,A denotes memory addressed indirectly by HL and is not another physical register.

A is the accumulator carrying the latest byte returned by IN. B is an 8-bit down-counter initialized to five; DCR B updates the zero condition used by JNZ. INX H changes the register-pair pointer, so successive MOV operations reach consecutive destination addresses. The zero flag is tested after decrement, ensuring five iterations.

The operand 20 designates an I/O port in the separate 8085 port-address space, whereas 5000 and 5001 are memory addresses. GET labels the IN instruction in code and is the branch destination. At completion the original pointer storage cells need not change, B is zero, A contains the last input value, and HL points one location beyond the five-byte output block, subject to address wraparound.

Original paper, page 13