92.8k views
2 votes
Write an ALP to separate odd and even numbers from an array of N numbers; arrange odd

numbers in address 2000h, even numbers in address 3000h using 8086.

1 Answer

3 votes

Answer:

2000H LXI H, 2000H memory pointer first is initialized

2003H LXI D, 2100H memory pointer second is initialized

2006H MVI C, 32H the counter, is initialized

2008H MOV A, M We achieve the number

2009H ANI 0lH We now check for an odd number

200BH JZ 2011H If it is even then never store it

200EH MOV A, M Now we achieve the number again

200FH STAX D The number is stored in the result list.

2010 H INX D Pointer 2 is incremented

2011 H INX H Pointer 1 is incremented

2012H DCR C The counter is decremented

2013H JNZ 2008H If it is not zero, then repeat it

2016H LXI H, 2000H the memory pointer 1st, is initialized

2019H LXI D, 2200H the memory pointer 2nd is initialized

201CH MVI C, 32H the counter, is initialized

201EH MOV A, M Achieve the number

201FH ANI 0lH Test whether it is even or not

2021H JNZ 2027H If it is odd, then never store it

2024H MOV A, M Achieve the number

2025H STAX D Save the number in the result list

2026H INX D Now increment the pointer number 2

2027H INX H Increment pointer number 1

2028H DCR C Counter is to be decremented

2029H JNZ 201EH If! 0 then repeat it

202CH HLT Stop

Step-by-step explanation:

Please check the answer section.

User JerMah
by
4.8k points