Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

8085 program to separate odd and even nos from a given list of numbers

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Problem: Write an assembly language program in 8085 microprocessor to separate odd and even numbers from the given list of 50 numbers. Store odd nos in another list starting from memory location 2100H. Store even nos in another list starting from memory location 2200H. Starting address of the list is 2000H.


A number is said to be odd if its least significant bit is 1 otherwise it is even. Therefore to identify whether the number is even or odd, we perform AND operation with 01 by the help of ANI instruction. If the number is odd then we will get 01 otherwise 00 in the accumulator. ANI instruction also affects the flags of 8085. Therefore if accumulator contains 00 then zero flag gets set otherwise it gets reset.


  1. Load the memory location 2000 in HL register pair.
  2. Load the memory location 2100 in DE register pair for storing odd numbers.
  3. Store the number of elements in register C.
  4. Move the next number in the list to accumulator.
  5. Perform AND operation with 01H to check whether the number is even or odd.
  6. If even, jump to step 9.
  7. Get the number in accumulator and store in the memory location pointed by DE.
  8. Increment DE.
  9. Increment HL. Decrement C.
  10. If C is not zero, jump to step 4.

Perform similarly above steps for storing even numbers.


Memory LocationMneumonicsComments
2000HLXI H, 2000HInitialize memory pointer 1
2003HLXI D, 2100HInitialize memory pointer 2
2006HMVI C, 32HInitialize counter
2008HMOV A, MGet the number
2009HANI 0lHCheck for odd number
200BHJZ 2011HIf EVEN, don’t store
200EHMOV A, MGet the number
200FHSTAX DStore the number in result list
2010HINX DIncrement pointer 2
2011HINX HIncrement pointer l
2012HDCR CDecrement counter
2013HJNZ 2008HIf not zero, repeat
2016HLXI H, 2000HInitialize memory pointer l
2019HLXI D, 2200HInitialize memory pointer2
201CHMVI C, 32HInitialize counter
201EHMOV A, MGet the number
201FHANI 0lHCheck for even number
2021HJNZ 2027HIf ODD, don’t store
2024HMOV A, MGet the number
2025HSTAX DStore the number in result list
2026HINX DIncrement pointer 2
2027HINX HIncrement pointer l
2028HDCR CDecrement counter
2029HJNZ 201EHIf not zero, repeat

My Personal Notes arrow_drop_up
Last Updated : 28 May, 2019
Like Article
Save Article
Similar Reads