8085 program to find larger of two 8 bit numbers

MicrocontrollerMicroprocessor8085

In this program we will see how to find the larger of two numbers.

Problem Statement

Write 8085 Assembly language program to find the larger number of two 8-bit number store dat location 8000H and 8001H.

Discussion

This checking is done by using the CMP instruction. This instruction is very similar to the SUB instruction. The only difference is that it does not update the value of Accumulator after executing. So after comparing, if the CY flag is set, it means that the first number is smaller, and the second one is larger

Input

First input

Address
Data
.
.
.
.
.
.
8000
FD
8001
23
.
.
.
.
.
.

second input

Address
Data
.
.
.
.
.
.
8000
59
8001
75
.
.
.
.
.
.


Flow Diagram

Program

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


LXI H,8000H
Point to the first number
F003
46


MOV B,M
Load the first number to B
F004
23


INX H
Point to next location
F005
7E


MOV A,M
Get the second number to A
F006
B8


CMP B
Compare B with A
F007
D2, 0B, F0


JNC STORE
Is CY = 0,jump to Store
F00A
78


MOV A,B
Load A with second number
F00B
32, 50, 80
STORE
STA 8050H
Store the number into memory
F00E
76


HLT
Terminate the program


Output

First output

Address
Data
.
.
.
.
.
.
8050
FD
.
.
.
.
.
.


Second output

Address
Data
.
.
.
.
.
.
8050
75
.
.
.
.
.
.
raja
Published on 22-Jan-2019 15:13:08
Advertisements