# 8085 program to find minimum value of digit in the 8 bit number

Problem – Write an assembly language program in 8085 microprocessor to find minimum value of digit in the 8 bit number.

Example – Assume 8 bit number is stored at memory location 2050, and minimum value digit is stored at memory location 3050.

Algorithm –

1. Load the content of memory location 2050 in accumulator A.
2. Move the content of A in register B.
3. Perform AND operation of content of A with 0F and store the result in A.
4. Move the content of A in register C.
5. Move the content of B in A.
6. Reverse the content of A by using RLC instruction 4 times.
7. Perform AND operation of content of A with 0F and store the result in A.
8. Compare the contents of A and C by help of CMP C instruction.
9. Check if carry flag is set then jump to memory location 2013 otherwise move the content of C in A. Go to memory location 2013.
10. Store the value of A in memory location 3050.

Note – CMP C instruction compares the value of A and C. If A>C then carry flag becomes reset otherwise set.

Program –

MEMORY ADDRESS MNEMONICS COMMENT
2000 LDA 2050 A <- M[2050]
2003 MOV B, A B <- A
2004 ANI 0F A <- A (AND) 0F
2006 MOV C, A C <- A
2007 MOV A, B A <- B
2008 RLC Rotate content of accumulator right by 1 bit without carry
2009 RLC Rotate content of accumulator right by 1 bit without carry
200A RLC Rotate content of accumulator right by 1 bit without carry
200B RLC Rotate content of accumulator right by 1 bit without carry
200C ANI 0F A <- A (AND) 0F
200E CMP C A – C
200F JC 2013 Jump if CY = 1
2012 MOV A, C A <- C
2013 STA 3050 M[3050] <- A
2016 HLT END

Explanation – Registers A, B, C are used for general purpose.

1. LDA 2050: loads the contents of memory location 2050 in A.
2. MOV B, A: moves the content of A in B.
3. ANI 0F: perform AND operation between contents of A and value 0F.
4. MOV C, A: moves the content of A in C.
5. MOV A, B: moves the content of B in A.
6. RLC: shift the content of A left by 1 bit without carry. Use this instruction 4 times to reverse the content of A.
7. ANI 0F: perform AND operation between contents of A and value 0F.
8. CMP C: compare contents of A, C and update the value of carry flag accordingly.
9. JC 2013: jump to memory location 2013 if CY = 1.
10. MOV A, C: moves the content of C in A.
11. STA 3050: stores the content of A in memory location 3050.
12. HLT: stops executing the program and halts any further execution.

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.