Professional Documents
Culture Documents
Q5A
a. ALP to count 02H
LABEL MNEMONICS COMMENTS
LXI H, D000H ;Load address to HL pair
MOV C, M ;Store the length of block to C
MVI B, 00H ;Initialise B to 0 for counting data byte 02H
UP: INX H ;Increment HL pair
MOV A,M ;copy value at memory to Acc
CPI 02H ;compare acc with 02H
JNZ DN ;If not equal, jump down on DN
INR B ;If equal, increment B
DN: DCR C ;decrement block counter
JNZ UP ;jump up for further value comparison
MOV A,B ;copy count of 02H to accumulator
STA D100H ;Store the count from Acc to Memory Location