In this program, we will write an 8085 Program to find the smallest number in the array in the 8085 microprocessor with a program flow chart and explanation of the program.
8085 Program to find the smallest number in the array
Program Statement
Given an array of numbers. Write in the assembly language program of 8085 to find the smallest number amongst the numbers in the array. Assume that the length of the array is stored in memory location D000H and the array begins from memory location D001H. Store the minimum number at memory location E000H.
Explanation of Program
- We have an array of 10 numbers for e.g. So we initialize the counter with 10. Also, we initialize a pointer to point these numbers.
- Compare the first number with an initial number. If number < Minimum number, save number otherwise increment the pointer to compare the next number. Decrement counter, compare till all the numbers are compared.
- Store the minimum number in the memory location E000H.
Flow Chart of Program
Assembly Language Program
Label | Instruction | Comment |
---|---|---|
LDA D000H | Load counting accumulator | |
MOV C, A | Initialize counter | |
LXI H, D001H | Initialize memory pointer | |
MOV A, M | ||
INX M | increment memory pointer | |
BACK: | CMP M | Is number < minimum |
JC SKIP | ||
MOV A, M | if number < minimum then interchange | |
SKIP: | INX H | Increment memory pointer |
DCR C | Decrement counter | |
JNZ BACK | If count ≠ 0, repeat | |
STA E000H | Store minimum number | |
HLT | Terminate program execution |