Statement: Write an 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.
Source Program:
LXI H, 2200H : Initialize memory pointer l
LXI D, 2300H : Initialize memory pointer2
MVI C, 32H : Initialize counter
BACK:MOV A, M : Get the number
ANI 0lH : Check for even number
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 l
DCR C : Decrement counter
JNZ BACK : If not zero, repeat
HLT : Stop
please give easy code
ReplyDeleteTHIS PROGRAM IS NOT WORKING ...IT STORING ALL NUMBERS IN DESTINATION
ReplyDeleteinstead of ANI and JNZ lines
ReplyDeletesubstitute them by
RAR
JC (if odd it will have carry, this way separate even from odd.)
How will the carry become 1 for odd numbers?
Delete