Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
8085 program to find smallest number between two numbers
In this program we will see how to find the smallest of two numbers.
Problem Statement
Write 8085 Assembly language program to find the smallest 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 |
DA, 0B, F0 |
|
JC STORE |
Is CY = 1,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 |
23 |
| . . . |
. . . |
Second output
| Address |
Data |
|---|---|
| . . . |
. . . |
| 8050 |
59 |
| . . . |
. . . |
Advertisements
