8085 program to find maximum and minimum of 10 numbers

MicrocontrollerMicroprocessor8085

In this program we will see how to find the maximum and minimum number in a block data.

Problem Statement

Write 8085 Assembly language program to find the maximum and minimum number in a block often 8-bit numbers.

Discussion

In this program we are taking the first number of the block into register D and E. The D will store the minimum number, and E will store maximum number. In each iteration we will check whether the number is smaller than D or not, if it is smaller, then update D with the new number, and then compare it again with E to check whether the number is larger than E or not. If larger, then update E with the new number.

Input

Address
Data
.
.
.
.
.
.
8000
55
8001
22
8002
88
8003
77
8004
11
8005
99
8006
44
8007
AA
8008
33
8009
66
.
.
.
.
.
.


Flow Diagram

Program

Address
HEX Codes
Label
Mnemonics
Comments
F000
21, 00, 80


LXI H,8000H
Load the initial address
F003
0E, 0A


MVI C,0AH
Load the count of numbers
F005
56


MOV D,M
Load the first number from memory
F006
5A


MOV E,D
Also load the first number to E
F007
23


INX H
Point to next location
F008
0D


DCR C
Decrease the count
F009
7E
LOOP
MOV A,M
Load the number from memory to A
F00A
BA


CMP D
Compare D with A
F00B
D2, 0F, F0


JNC SKIP
If CY = 0, A is not smaller
F00E
57


MOV D,A
Update D with A
F00F
BB
SKIP
CMP E
Compare E with A
F010
DA, 14, F0


JC DO
if CY = 1, A is not larger
F013
5F


MOV E,A
Update E with A
F014
23
DO
INX H
Point to next location
F015
0D


DCR C
Decrease C by1
F016
C2, 09, F0


JNZ LOOP
Go to loop
F019
21, 50, 80


LXI H,8050H
Point to destination address
F01C
72


MOV M,D
Store the smallest number
F01D
23


INX H
Point to next location
F01E
73


MOV M,E
Store the largest number
F01F
76


HLT
Terminate the program


Output

Address
Data
.
.
.
.
.
.
8050
11
8051
AA
.
.
.
.
.
.
raja
Published on 22-Jan-2019 10:39:48
Advertisements