Q. A set of ten bytes are stored in memory locations starting with address C000H. Write a
program to check each byte and save the bytes that are higher than 40H and lower than
64H in memory locations starting from C200H.
Solution:
LXI H, C000H
LXI D, C200H
MVI C, 0AH
LABEL1: MVI A, 40H
CMP M
JNC LABEL2 ; reject less than or equal to 40H
MOV A, M
CPI 64H
JNC LABEL2 ; reject greater than 64H
STAX D
INX D
LABEL2: INX H
DCR C
JNZ LABLE1
HLT
program to check each byte and save the bytes that are higher than 40H and lower than
64H in memory locations starting from C200H.
Solution:
LXI H, C000H
LXI D, C200H
MVI C, 0AH
LABEL1: MVI A, 40H
CMP M
JNC LABEL2 ; reject less than or equal to 40H
MOV A, M
CPI 64H
JNC LABEL2 ; reject greater than 64H
STAX D
INX D
LABEL2: INX H
DCR C
JNZ LABLE1
HLT
Comments
Post a Comment