8085 program to find maximum of two 8 bit numbers

Problem – Write a assembly language program to find maximum of two 8 bit numbers in 8085 microprocessor.

Assumptions – Starting memory locations and output memory locations are 2050, 2051 and 3050 respectively.

Example –

Algorithm –

  1. Load value in the accumulator
  2. Then, copy the value to any of the register
  3. Load next value in the accumulator
  4. Compare both values
  5. Check carry flag, if reset then jump to the required address to store the value
  6. Copy the result in the accumulator
  7. Store the result at the required address

Program –

2000 LDA 2050 A<-25
2003 MOV B, A B<-25
2004 LDA 2051 A<-15
2007 CMP B A-B
2008 JNC 200C Jump if Carry flag is Reset(Carry flag = 0)
200B MOV A, B A<-25
200C STA 3050 3050<-25
200F HLT Terminates the program

Explanation –

  1. LDA 2050: loads value at memory location 2050
  2. MOV B, A: assigns value of A to B
  3. LDA 2051: loads value at memory location 2051
  4. CMP B: compare values by subtracting B from A
  5. JNC 200C: jump at memory location 200C if carry flag is Reset(Carry flag = 0)
  6. STA 3050: store result at memory location 3050
  7. HLT: terminates the program

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.