
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find Maximum of Two 8-Bit Numbers in 8085
In this program we will see how to find the maximum of two numbers.
Problem Statement
Write 8085 Assembly language program to find the maximum number of two 8-bit number stored at 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 |
. . . |
. . . |
Advertisements