8085 program to find smallest number between two numbers

Problem – Write an assembly language program to find smallest number between two number’s.

Example –

Algorithm –

  1. Load the content from memory location
  2. Move content of Accumulator into Register B
  3. Load the content from Memory location
  4. Compare the content of Register B
  5. If carry flag is equal to 1 go to step 7
  6. Move content of Register B into Accumulator
  7. Store the content into Memory
  8. End of program

Program –

Memory Memonics Use Operand Comments
2000 LDA [2500] [A]<-[2500]
2003 MOV B, A [B]<-[A]
2004 LDA 2501 [A]<-[2501]
2007 CMP B [A]<-[A]-[B]
2008 JC * [200C] jump carry
200B MOV B, A [A]<-[B]
200C STA [2502] [A]->[2502]

Explanation –

  1. LDA is used to load accumulator (3 Byte instruction).
  2. CMP is used to compaire the content of accumulator (1 Byte instruction).
  3. STA is used to store accumulator direct using 16-bit address (3 Byte instruction).
  4. JC jump if carry (3 Byte instruction).

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

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.