8085 program to find larger of two 8 bit numbers
Problem – Write a program in 8085 microprocessor to find out larger of two 8-bit numbers, where numbers are stored in memory address 2050 and 2051, and store the result into memory address 3050.
Example –

Algorithm –
- Load two numbers from memory 2050 & 2051 to register L and H .
- Move one number(H) to Accumulator A and subtract other number(L) from it.
- if result is positive then move the number(H) to A and store value of A at memory address 3050 and stop else move the number(L) to A and store value of A at memory address 3050 and stop.
Program –
| MEMORY ADDRESS | MNEMONICS | COMMENT |
|---|---|---|
| 2000 | LHLD 2050 | H<-(data at 2051)&L<-(data at 2050) |
| 2003 | MOV A, H | A<-H |
| 2004 | SUB L | A<-A-L |
| 2005 | JP 200D | JUMP TO 200D IF NO. IS POSITIVE |
| 2008 | MOV A, L | A<-L |
| 2009 | STA 3050 | A->(in memory 3050) |
| 200C | HLT | STOP |
| 200D | MOV A, H | A<-H |
| 200E | STA 3050 | A->(in memory 3050) |
| 2011 | HLT | STOP |
Explanation –
- LHLD 2050: load data from memory 2050 & 2051 to register L and H.
- MOV A, H: transfer contents of register H to A.
- SUB L: subtract contents of register L from A and store it to A.
- JP 200D: jump to address 200D if result is positive.
- MOV A, L: transfer contents of register L to A.
- STA 3050: store data of A to memory address 3050.
- HLT:: END.
- MOV A, H: transfer contents of register H to A.
- STA 3050: store data of A to memory address 3050.
- HLT: END.
Recommended Posts:
- 8085 program to find the sum of series of even numbers
- 8085 program to find the sum of first n natural numbers
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to find smallest number between two numbers
- 8085 program to find maximum and minimum of 10 numbers
- 8085 program to count total odd numbers in series of 10 numbers
- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to add 2-BCD numbers
- 8085 program to add two 16 bit numbers
- 8085 program to add two 8 bit numbers
- 8085 program to sum of two 8 bit numbers without carry
- 8085 program to add numbers in an array
- 8085 program to divide two 16 bit numbers
- 8085 program to multiply two 16-bit numbers
- 8085 program to multiply two 8 bit numbers
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.



