Practice over 1000+ GATE-level questions from this topic!
Designed to match the latest GATE pattern with topic-wise precision, difficulty tagging, and detailed solutions.
A subroutine PROG1 written in the 8085 assembly language is given below. At entry to this program, the values of different registers in HEX are. A=05; BC=0000; DE=5472; HL=4528, All the flags are set to 1. Determine the register contents and condition of the zero and carry flags after the execution of the program. (i.e., after executing RET statement). What does the program accomplish?
PROG1 MOV A, E
ADD L
DAA
MOV L, A
MOV A, D
ADC H
DAA
MOV H, A
MVI A, 00H
RAL
RET
Contents of Registers,
HL = 0000H
BC = 0000H
DE = 5472H
A = 01H
CY = 0 and Z =1
Contents of Registers,
HL = 000H
BC = 0000H
DE = 5472H
A = 01H
CY = 1 and Z =0
Contents of Registers,
HL = 0000H
BC = 0000H
DE = 5472H
A = 10H
CY = 0 and Z =1
Contents of Registers,
HL = 0000H
BC = 0000H
DE = 5472H
A = 01H
CY = 1 and Z =1
PROG1 MOV A, E; A = 72H, flags unchanged
ADD L; A = A + L = 9AH (1001 1010); Z = 0, CY = 0
DAA;
Since, the lower nibble of accumulator is greater than 09H then 06H is added to lower nibble which makes the result A0H. Now the higher order nibble becomes greater than 09H so 06H is added to higher order nibble. Hence, A = 00H. So Carry Flag is set and zero flag is also set.

Contents of Registers,
HL = 0000H
BC = 0000H
DE = 5472H
A = 01H
CY = 0 and Z =1