8085 program to find maximum and minimum of 10 numbers
Problem – Write an assembly language program in 8085 microprocessor to find maximum and minimum of 10 numbers.
Minimum: 01H, Maximum: FFH
In CMP instruction:
If Accumulator > Register then carry and zero flags are reset
If Accumulator = Register then zero flag is set
If Accumulator < Register then carry flag is set
Assumption – List of numbers from 2050H to 2059H and output at 2060H and 2061H.
- Maximum number is stored in B register and minimum in C register
- Load counter in D register
- Load starting element in Accumulator, B and C register
- Compare Accumulator and B register
- If carry flag is not set then transfer contents of Accumulator to B. Else, compare Accumulator with C register, if carry flag is set transfer contents of Accumulator to C
- Decrement D register
- If D>0 take next element in Accumulator and go to point 4
- If D=0, store B and C register in memory
- End of program
|LXI H, 2050H
|Load starting address of list
|MOV B, M
|MOV C, M
|MVI D, 0AH
|Counter for 10 elements
|MOV A, M
|Retrieve list element in Accumulator
|Compare element with maximum number
|Jump to MIN if not maximum
|MOV B, A
|Transfer contents of A to B as A > B
|Compare element with minimum number
|Jump to SKIP if not minimum
|MOV C, A
|Transfer contents of A to C if A < minimum
|Jump to LOOP if D > 0
|LXI H, 2060H
|Load address to store maximum
|MOV M, B
|Move maximum to 2060H
|MOV M, C
|Move minimum to 2061H
- One by one all elements are compared with B and C register.
- Element is compared with maximum, if it greater than maximum then it is stored in B register. Else, it is compared with minimum and if it is less than minimum then it stored in C register.
- Loop executes 10 number of times.
- At the end of 10 iterations, maximum and minimum are stored at 2060H and 2061H respectively.
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.
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 maximum and minimum of 10 numbers requires a significant amount of programming effort, particularly if the program needs to handle multiple input values or complex data structures.
Share your thoughts in the comments
Please Login to comment...