GATE / CS ARCHIVE

GATE CSE 1995 / QUESTION 16(b)

Read the initialized 8085 registers

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

GATE 1995, Q16(b) Descriptive
Report issue

Instructions & Addressing Modes

Question 16(b), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What are the initial contents of A and B for the search?
Question 16(b), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What are the initial contents of A and B for the search?
Tap to enlarge
Answer & solution

Answer: A=05H and B=0AH (decimal 5 and 10). (no official key was published)

MVI means “move immediate”: it loads the byte written in the instruction directly into the named register. MVI B,0AH sets B to hexadecimal 0A, which is decimal 10. MVI A,05H then sets the accumulator to hexadecimal 05, which is decimal 5. These are the initialized values just before CALL SUB, not claims about unspecified power-on register contents.

LXI H,1C40H loads the separate HL pair and does not change either A or B. CALL changes control flow and the stack, not these initialized register values. During the routine A remains the search key 05H because CMP only changes flags. B is the loop counter and can subsequently decrease. The source asks for the initial values, so a final B value derived from an assumed memory image would answer a different question.

Original paper, page 7