The Wayback Machine - https://web.archive.org/web/20240822104252/https://www.geeksforgeeks.org/8085-program-find-maximum-minimum-10-numbers/
Open In App

8085 program to find maximum and minimum of 10 numbers

Last Updated : 25 Apr, 2023
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Problem – Write an assembly language program in 8085 microprocessor to find maximum and minimum of 10 numbers. 

Example – 
 

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. 

Algorithm –  

  1. Maximum number is stored in B register and minimum in C register
  2. Load counter in D register
  3. Load starting element in Accumulator, B and C register
  4. Compare Accumulator and B register
  5. 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
  6. Decrement D register
  7. If D>0 take next element in Accumulator and go to point 4
  8. If D=0, store B and C register in memory
  9. End of program

Program- 

Address Label Instruction Comment
2000H   LXI H, 2050H Load starting address of list
2003H   MOV B, M Store maximum
2004H   MOV C, M Store minimum
2005H   MVI D, 0AH Counter for 10 elements
2007H LOOP MOV A, M Retrieve list element in Accumulator
2008H   CMP B Compare element with maximum number
2009H   JC MIN Jump to MIN if not maximum
200CH   MOV B, A Transfer contents of A to B as A > B
200DH MIN CMP C Compare element with minimum number
200EH   JNC SKIP Jump to SKIP if not minimum
2011H   MOV C, A Transfer contents of A to C if A < minimum
2012H SKIP INX H Increment memory
2013H   DCR D Decrement counter
2014H   JNZ LOOP Jump to LOOP if D > 0
2017H   LXI H, 2060H Load address to store maximum
201AH   MOV M, B Move maximum to 2060H
201BH   INX H Increment memory
201CH   MOV M, C Move minimum to 2061H
201DH   HLT Halt

Explanation – 

  1. One by one all elements are compared with B and C register.
  2. 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.
  3. Loop executes 10 number of times.
  4. At the end of 10 iterations, maximum and minimum are stored at 2060H and 2061H respectively.

Advantages:

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.
 

Disadvantages:

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.


Previous Article
Next Article

Similar Reads

8085 program to find maximum of two 8 bit numbers
Problem - Write a assembly language program to find maximum of two 8 bit numbers in 8085 microprocessor. Assumptions - Starting memory locations and output memory locations are 2050, 2051 and 3050 respectively. Example - Algorithm - Load value in the accumulator Then, copy the value to any of the register Load next value in the accumulator Compare
1 min read
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 - Load the content of memory location 2050 in accumulator A.Move the content of A in register B.
3 min read
8085 program to find larger of two 8 bit numbers
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 - Load two numbers from memory 2050 &amp; 2051 to register L and H .Move one number(H) to Accumulator A and subtract other number(L) fr
3 min read
8085 program to find the sum of first n natural numbers
Problem - Write an assembly language program for calculating the sum of first n natural numbers using 8085 microprocessor. Example - Input : 04H Output : 0AH as 01+02+03+04 = 10 in decimal =&gt; 0AH The formula for calculating the sum of first n natural numbers is [Tex]\frac{(n(n+1))}{2} [/Tex]. Algorithm - With n as the input, increment it to obta
3 min read
8085 program to find the sum of series of even numbers
Problem - Calculate the sum of series of even numbers from the given list of numbers. The length of the list is in memory location 2200H and the series begins from memory location 2201H. Result will store at memory location 2210H. Examples - Input : 2200H= 4H 2201H= 20H 2202H= l5H 2203H= l3H 2204H= 22H Output : Result 2210H = 42H Program - MNEMONIC
2 min read
8085 program to separate odd and even nos from a given list of numbers
Problem: Write an assembly language program in 8085 microprocessor to separate odd and even numbers from the given list of 50 numbers. Store odd nos in another list starting from memory location 2100H. Store even nos in another list starting from memory location 2200H. Starting address of the list is 2000H. Examples: Explanation: A number is said t
2 min read
8085 program to search a number in an array of n numbers
Problem - Write an assembly language program in 8085 to search a given number in an array of n numbers. If number is found, then store F0 in memory location 3051 otherwise store 0F in 3051. Assumptions - Count of elements in an array is stored at memory location 2050. Array is stored from starting memory address 2051 and number which user want to s
4 min read
8085 program to add two 8 bit numbers
Problem - Write an assembly language program to add two 8 bit numbers stored at address 2050 and address 2051 in 8085 microprocessor. The starting address of the program is taken as 2000. Example - Algorithm - Load the first number from memory location 2050 to accumulator.Move the content of accumulator to register H.Load the second number from mem
2 min read
8085 program to multiply two 8 bit numbers
Problem - Multiply two 8 bit numbers stored at address 2050 and 2051. Result is stored at address 3050 and 3051. Starting address of program is taken as 2000. Example - Algorithm - We are taking adding the number 43 seven(7) times in this example.As the multiplication of two 8 bit numbers can be maximum of 16 bits so we need register pair to store
3 min read
8085 program to add two 16 bit numbers
Problem: Write an assembly language program to add two 16 bit numbers by using: 8-bit operation16-bit operation Example: 1. Addition of 16-bit numbers using 8-bit operation: It is a lengthy method and requires more memory as compared to the 16-bit operation. Algorithm: Load the lower part of the first number in the B register.Load the lower part of
3 min read
8085 program to swap two 8-bit numbers
Problem: Write an assembly language program to swap two 8-bit numbers stored in an 8085 microprocessor. Assumption: Suppose there are two 8-bit numbers. One 8-bit number is stored at location 2500 memory address and another is stored at location 2501 memory address. Let 05 be stored at location 2500 and 06 be stored at location 2501 (not necessaril
4 min read
8085 program to add three 16 bit numbers stored in registers
Problem - Write an assembly language program to add three 16 bit numbers stored in register HL, DE, BC and store the result in DE with minimum number of instructions. Example - Assumptions - Numbers to be added are already stored in register HL, DE, BCNumbers stored in register are such that final result should not be greater than FFFF DAD D perfor
3 min read
8085 program to convert binary numbers to gray
Prerequisite - Binary to/from Gray Code Problem – Write an assembly language program in 8085 microprocessor to convert binary numbers to gray. Example - Algorithm – Set the Carry Flag (CY) to 0.Load the data from address 2050 in A.Move the data of A(accumulator) into register B.Rotate the bits of A to right.XOR the contents of register A and B.Stor
2 min read
8085 program to subtract two 8-bit numbers with or without borrow
Problem – Write a program to subtract two 8-bit numbers with or without borrow where first number is at 2500 memory address and second number is at 2501 memory address and store the result into 2502 and borrow into 2503 memory address. Example – Algorithm – Load 00 in a register C (for borrow)Load two 8-bit number from memory into registersMove one
3 min read
8085 program to add 2-BCD numbers
Problem – Write a program to add 2-BCD numbers where starting address is 2000 and the numbers is stored at 2500 and 2501 memory addresses and store sum into 2502 and carry into 2503 memory address. Example – Algorithm – Load 00H in a register (for carry)Load content from memory into register pairMove content from L register to accumulatorAdd conten
3 min read
8085 program to multiply two 8 bit numbers using logical instructions
Prerequisite - Logical instructions in 8085 microprocessor Problem - Write a assembly language program multiply two 8 bit numbers and store the result at memory address 3050 in 8085 microprocessor. Example - The value of accumulator(A) after using RLC instruction is: A = 2n*A Where n = number of times RLC instruction is used. Assumptions - Assume t
2 min read
8085 program to swap two 16 bit numbers using Direct addressing mode
Problem - Write a program to swap two 16-bit numbers using direct addressing mode where starting address is 2000 and the first 16-bit number is stored at 3000 and the second 16-bit number is stored at 3002 memory address. Example – Algorithm – Load a 16-bit number from memory 3000 into a register pair (H-L)Exchange the register pairsLoad a 16-bit n
2 min read
8085 program to swap two 8 bit numbers using Direct addressing mode
Problem - Write a program to swap two 8-bit numbers using direct addressing mode where starting address is 2000 and the first 8-bit number is stored at 3000 and the second 8-bit number is stored at 3001 memory address. Example – Algorithm – Load a 8-bit number from memory 3000 into accumulatorMove value of accumulator into register HLoad a 8-bit nu
2 min read
8085 program to divide two 8 bit numbers
Problem - Write 8085 program to divide two 8 bit numbers. Example - Algorithm - Start the program by loading the HL pair registers with address of memory location. Move the data to B Register. Load the second data into accumulator. Compare the two numbers to check carry. Subtract two numbers. Increment the value of carry. Check whether the repeated
2 min read
8085 program to add numbers in an array
Problem - Write an assembly language program to add hexadecimal numbers stored in continuous memory or in an array. Assumption - Suppose the size of the array is stored at memory location 2050 and the base address of the array is 2051. The sum will be stored at memory location 3050 and carry will be stored at location 3051. Example - Algorithm - Lo
2 min read
8085 program to subtract two 16-bit numbers with or without borrow
Problem - Write an assembly language program in 8085 microprocessor to subtract two 16 bit numbers. Assumption - Starting address of program: 2000Input memory location: 2050, 2051, 2052, 2053Output memory location: 2054, 2055 Example - INPUT: (2050H) = 19H (2051H) = 6AH (2052H) = 15H (2053H) = 5CH OUTPUT: (2054H) = 04H (2055H) = OEH RESULT: Hence w
2 min read
8085 program to multiply two 16-bit numbers
Problem: Write an assembly language program in 8085 microprocessor to multiply two 16 bit numbers. Assumption: The starting address of program: 2000 Input memory location: 2050, 2051, 2052, 2053 Output memory location: 2054, 2055, 2056, 2057 Example: INPUT: (2050H) = 04H (2051H) = 07H (2052H) = 02H (2053H) = 01H OUTPUT: (2054H) = 08H (2055H) = 12H
3 min read
8085 program to divide two 16 bit numbers
Problem - Write an assembly language program in 8085 microprocessor to divide two 16 bit numbers. Assumption - Starting address of program: 2000 Input memory location: 2050, 2051, 2052, 2053 Output memory location: 2054, 2055, 2056, 2057. Example - INPUT: (2050H) = 04H (2051H) = 00H (2052H) = 02H (2053H) = 00H OUTPUT: (2054H) = 02H (2055H) = 00H (2
4 min read
8085 program to sum of two 8 bit numbers without carry
Problem - Write an assembly language program to sum two 8 bit numbers without using carry operation in 8085 microprocessor. Assumption: The starting address of the program is 2000. Memory address of the first number is 2050. Memory address of the second number is 2051. Memory address of result is 2052. Example: Input: 2050: 03 : 2-51: 04 Output: 20
2 min read
8085 program to find 1's and 2's complement of 8-bit number
Problem - Write a program to find 1's and 2's complement of 8-bit number where starting address is 2000 and the number is stored at 3000 memory address and store result into 3001 and 3002 memory address. Example - Algorithm - Load the data from memory 3000 into A (accumulator)Complement content of accumulatorStore content of accumulator in memory 3
2 min read
8085 program to find 1’s and 2’s complement of 16-bit number
Prerequisite - 8085 program to find 1’s and 2’s complement of 8-bit number Problem - – Write a program to find 1’s and 2’s complement of 16-bit number where starting address is 2000 and the number is stored at 3000 memory address and store result into 3002 and 3004 memory address. Example - Algorithm - Load a 16-bit number from memory 3000 into a r
2 min read
8085 program to find the element that appears once
Prerequisite - Find the element that appears once in an array where every other element appears twice Problem – Given 11 numbers, write an assembly language program to find the element that appears once where 5 numbers appear twice and one element appears once. Examples: Input : [01H, 02H, 09H, 01H, 01H, 02H, 0AH, 01H, 09H, 03H, 03H] Output : 0AH E
2 min read
8085 program to find the factorial of a number
Problem - Write an assembly language program for calculating the factorial of a number using 8085 microprocessor. Example - Input : 04H Output : 18H as 04*03*02*01 = 24 in decimal =&gt; 18H In 8085 microprocessor, no direct instruction exists to multiply two numbers, so multiplication is done by repeated addition as 4x3 is equivalent to 4+4+4 (i.e.
2 min read
8085 program to find square root of a number
Problem – Write an assembly language program in 8085 microprocessor to find square root of a number. Example - Assumptions - Number, whose square root we need to find is stored at memory location 2050 and store the final result in memory location 3050. Algorithm - Assign 01 to register D and ELoad the value, stored at memory location 2050 in accumu
3 min read
8085 program to find sum of digits of 8 bit number
Problem: Write an assembly language program in 8085 microprocessor to find the sum of digits of an 8-bit number. Example: Assumptions: Addresses of input data and output data are 2050 and 3050 respectively. Algorithm: Load value stored at memory location 2050 in accumulator AMove the value of accumulator A in register B to process 43H.Perform maski
5 min read
three90RightbarBannerImg