Q. A bar code scanner scans the boxes being shipped from the loading dock and records all
the codes in memory starting from AB00H; the end of the data is indicated by the byte
00H. The code 0010 0001 is assigned to 21 inches television sets. Write a program to
count the number of 21 inches television sets that were shipped from the loading dock.
Solution:
LXI H, AB00H
MVI C, 00H
LABEL1: MOV A, M
CPI 00H ; check for the end of the data 00H
JZ END
CPI 21H ; check for code 0010 0001 (21H)
JNZ LABEL2
INR C
LABEL2: INX H
JMP LABEL1
END: MOV A, C ; store the count at BB00H (not mentioned in the question)
STA BB00H
HLT
the codes in memory starting from AB00H; the end of the data is indicated by the byte
00H. The code 0010 0001 is assigned to 21 inches television sets. Write a program to
count the number of 21 inches television sets that were shipped from the loading dock.
Solution:
LXI H, AB00H
MVI C, 00H
LABEL1: MOV A, M
CPI 00H ; check for the end of the data 00H
JZ END
CPI 21H ; check for code 0010 0001 (21H)
JNZ LABEL2
INR C
LABEL2: INX H
JMP LABEL1
END: MOV A, C ; store the count at BB00H (not mentioned in the question)
STA BB00H
HLT
Comments
Post a Comment