GATE / CS ARCHIVE

GATE CSE 1993 / QUESTION 20(a)

Five-byte input transfer

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

GATE 1993, Q20(a) Descriptive
Report issue

Instructions & Addressing Modes

Question 20(a), GATE 1993: Identify the function of this 8085 segment: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Question 20(a), GATE 1993: Identify the function of this 8085 segment: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Question 20(a), GATE 1993: Identify the function of this 8085 segment: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Tap to enlarge
Answer & solution

Answer: Read five bytes from input port 20 into consecutive memory cells starting at the address stored at 5000/5001. (no official key was published)

LHLD is a direct memory load of a register pair, not an immediate-address load: it loads L from memory[5000] and H from memory[5001]. Let the resulting 16-bit pointer be h. MVI initializes counter B to five. Each iteration reads one byte from the designated input port into accumulator A, and MOV M,A writes it to the memory location addressed by HL.

INX H advances the pointer by one. DCR B decreases the loop count and sets the zero flag. JNZ returns to GET while that count is nonzero. Thus the five iteration-start counts are 5,4,3,2,1, and exactly five input operations occur. The writes target h,h+1,…,h+4; afterward B=0 and HL=h+5, modulo the 16-bit address space.

The numeric radix of bare literals is not explicitly supplied; using customary hexadecimal assembly notation makes the pointer cells 5000H/5001H and port 20H. The transfer structure is unchanged under another assembler's radix convention. No input-ready polling or handshaking is implemented; the program assumes each IN yields a usable byte.

Original paper, page 13