Open In App

8085 program to find larger of two 8 bit numbers

Last Updated : 25 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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 –

  1. Load two numbers from memory 2050 & 2051 to register L and H .
  2. Move one number(H) to Accumulator A and subtract other number(L) from it.
  3. 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 –

  1. LHLD 2050: load data from memory 2050 & 2051 to register L and H.
  2. MOV A, H: transfer contents of register H to A.
  3. SUB L: subtract contents of register L from A and store it to A.
  4. JP 200D: jump to address 200D if result is positive.
  5. MOV A, L: transfer contents of register L to A.
  6. STA 3050: store data of A to memory address 3050.
  7. HLT:: END.
  8. MOV A, H: transfer contents of register H to A.
  9. STA 3050: store data of A to memory address 3050.
  10. HLT: END.

Advantages:

Efficient processing: The 8085 processor is capable of performing complex calculations quickly and efficiently, which can make it well-suited for programs that involve mathematical operations.
Flexibility: The 8085 instruction set is highly versatile, which can allow programmers to develop programs that are tailored to specific needs or applications.
Low cost: The 8085 microprocessor is a low-cost option compared to other microprocessors, which can make it accessible for a wide range of applications.
 

Disadvantages:

Limited memory: The 8085 microprocessor has a limited amount of memory, which can make it difficult to work with larger data sets or perform complex operations.
Limited processing power: While the 8085 is capable of performing complex calculations, it has limited processing power compared to newer microprocessors. This can make it less suitable for certain applications that require more advanced processing capabilities.
Difficulty of programming: The 8085 instruction set can be difficult to work with for programmers who are not familiar with assembly language. This can make it more challenging to develop programs for the 8085 compared to other microprocessors with higher-level programming languages. Additionally, finding the larger of two numbers requires a significant amount of programming effort, particularly if the program needs to handle multiple input values or complex data structures.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads