Skip to content
Related Articles

Related Articles

8085 program to find larger of two 8 bit numbers
  • Last Updated : 22 May, 2018
GeeksforGeeks - Summer Carnival Banner

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 ADDRESSMNEMONICSCOMMENT
2000LHLD 2050H<-(data at 2051)&L<-(data at 2050)
2003MOV A, HA<-H
2004SUB LA<-A-L
2005JP 200DJUMP TO 200D IF NO. IS POSITIVE
2008MOV A, LA<-L
2009STA 3050A->(in memory 3050)
200CHLTSTOP
200DMOV A, HA<-H
200ESTA 3050A->(in memory 3050)
2011HLTSTOP

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.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :