Separate even numbers from given numbers
Statement : Writean assembly language program to separate even numbers from the given list of 50 numbers and store them in the another list starting from 2300H. Assume starting address of 50 number list is 2200H.
LXI H, 2200H : “Initialize memory pointer 1”
LXI D, 2300H : “Initialize memory pointer2”
BACK:MOV A, M : “Get the numbr”
ANI 01H : “Check for even number”
Microprocessor Programs
JNZ SKIP : “If ODD, don’t store”
MOV A, M : “Get the number”
STAX D : “Store the number in result list”
INX D : “Increment pointer 2”
SKIP: INX H : “Increment pointer 1”
DCR C : “Decrement counter”
JNZ BACK : “If not zero, repeat”
HLT : “Stop”
LXI H, 2200H : “Initialize memory pointer 1”
LXI D, 2300H : “Initialize memory pointer2”
BACK:MOV A, M : “Get the numbr”
ANI 01H : “Check for even number”
Microprocessor Programs
JNZ SKIP : “If ODD, don’t store”
MOV A, M : “Get the number”
STAX D : “Store the number in result list”
INX D : “Increment pointer 2”
SKIP: INX H : “Increment pointer 1”
DCR C : “Decrement counter”
JNZ BACK : “If not zero, repeat”
HLT : “Stop”
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment