IAE Academy

GATE 2020 EE Q.54: solution and answer

GATE 2020 · EEQ.54 · 2 marks · NAT

An 8085 microprocessor accesses two memory locations (2001H) and (2002H), that contain 8-bit numbers 98H and B1H, respectively. The following program is executed:

LXI H,2001H
MVI A, 21H
INX H
ADD M
INX H
MOV M, A
HLT

At the end of this program, the memory location 2003H contains the number in decimal (base 10) form ________.

See the question in the paper

Answer and solution

ANSWER

Memory location 2003H ends up holding D2H, which is 210 in decimal.

Official answer: 210Source: Official answer key, GATE 2020 EE (IIT Delhi)

  1. loads the register pair with the address: , which points to the location holding .

  2. loads the immediate byte into the accumulator: .

  3. increments the 16-bit pair: . now refers to the location holding , not .

  4. computes : In binary, . There is no carry out of bit 7, so the sum fits in 8 bits.

  5. increments the pointer again: .

  6. stores the accumulator at the address in , so location now holds . stops the program.

  7. Convert to decimal: . Check: , , and .

KEY IDEA

In the 8085, always means the memory byte at the address in . Follow through each : the first one runs before , so the byte added is the one at (), and at is never read. The second moves to , and the sum is stored there.

WATCH OUT FOR

Adding as well, or adding it instead of , because the question names both locations. overflows 8 bits and gives the wrong answer. The other common slip is writing the answer in hex (), or converting as by mistaking the value of the digit D, which is 13.

From the GATE 2020 EE paper. Every question of this paper · Download the full paper · All 9 Processors & memory questions, with notes

More Processors & memory questions