
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
8085 Program to Add Two 8-Bit Numbers
In this program, we will see how to add two 8-bit numbers using 8085 microprocessor.
Problem Statement
Write 8085 Assembly language program to add two 8-bit numbers and store the result at locations 8050H and 8051H.
Discussion
To perform this task, we are using the ADD operation of 8085 Microprocessor. When the result of the addition is the 1-byte result, then the carry flag will not be enabled. When the result is exceeding the 1-byte range, then the carry flag will be 1
We are using two numbers at location 8000H and 8001H. When the numbers are 6CH and 24H, then the result will be (6C + 24 = 90) and when the numbers are FCH and 2FH, then the result will be (FC + 2F = 12B) Here the result is exceeding the range of 1-byte.
Input
first input
Address |
Data |
---|---|
. . . |
. . . |
8000 |
6C |
8001 |
24 |
. . . |
. . . |
second input
Address |
Data |
---|---|
. . . |
. . . |
8000 |
FC |
8001 |
2F |
. . . |
. . . |
Flow Diagram
Program
Address |
HEX Codes |
Labels |
Mnemonics |
Comments |
---|---|---|---|---|
F000 |
0E,00 |
MVIC,00H |
Clear C register |
|
F002 |
21,00, 80 |
LXIH,8000H |
Load initial address to get operand |
|
F005 |
7E |
MOVA, M |
Load Acc with a memory element |
|
F006 |
23 |
INX H |
Point to next location |
|
F007 |
46 |
MOVB, M |
Load B with the second operand |
|
F008 |
80 |
SUB B |
Add B with A |
|
F009 |
D2,0D, F0 |
JNC STORE |
When CY = 0, go to STORE |
|
F00C |
0C |
INR C |
Increase C by 1 |
|
F00D |
21,50, 80 |
STORE |
LXIH,8050H |
Load the destination address |
F010 |
77 |
MOVM, A |
Store the result |
|
F011 |
23 |
INX H |
Point to next location |
|
F012 |
71 |
MOVM, C |
Store the carry |
|
F013 |
76 |
HLT |
Terminate the program |
Output
first output
Address |
Data |
---|---|
. . . |
. . . |
8050 |
90 |
8051 |
00 |
. . . |
. . . |
second output
Address |
Data |
---|---|
. . . |
. . . |
8050 |
2B |
8051 |
01 |
. . . |
. . . |
Advertisements