- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 three 16 bit numbers stored in registers
In this program we will see how to add three 16-bit numbers stored in register pairs.
Problem Statement
Write 8085 Assembly language program to add three 16-bit numbers stored in register pair BC, DE and HL. Store the result at DE register pair.
Discussion
In this program we are storing the 16-bit numbers into BC, DE and HL pair. We have DAD D instruction which helps to add HL and DE register pair, and store the result into HL pair. After that copy BC to DE, then again perform DAD D to add them. Finally using XCHG we are storing them into DE register pair.
Here we are adding 0502H + 1211H + 2133H = 3846H
Input
Register | Data |
---|---|
BC | 0502 |
DE | 1211 |
HL | 2133 |
Flow Diagram
Program
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 01, 02, 05 | | LXI B,0502H | |
F003 | 11, 11, 12 | | LXI D,1211H | |
F006 | 21, 33, 21 | | LXI H,2133H | |
F009 | 19 | | DAD D | Add DE and HL, and Store into HL |
F00A | 50 | | MOV D,B | Copy B to D |
F00B | 59 | | MOV E,C | Copy C to E |
F00C | 19 | | DAD D | Add DE and HL (Actually BC), store into HL |
F00D | EB | | XCHG | Swap DE and HL |
F00E | 76 | | HLT | terminate the program |
Output
Register | Data |
---|---|
DE | 3846 |
Advertisements