- Trending Categories
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 swap two 8 bit numbers using Direct addressing mode
In this program we will see how to swap two numbers in direct addressing mode.
Problem Statement
Write 8085 Assembly language program to swap two 8-bit number stored at location 8000H and 8001H using direct addressing mode.
Discussion
In this case we are taking the number from memory by using the HL pair. The HL pair is storing the address of the data item. We are taking the first number into B register, and the second number to A register, then storing the content of B to the next position, and storing the value of A into first position.
Input
Address | Data |
---|---|
. . . | . . . |
8000 | CD |
8001 | 34 |
. . . | . . . |
Flow Diagram
Program
Address | HEX Codes | 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 the next number |
F005 | 7E | MOV A,M | Load the second number into A |
F006 | 70 | MOV M,B | Store first number to second position |
F007 | 2B | DCX H | Point to previous location |
F008 | 77 | MOV M,A | Store second number to first position |
F009 | 76 | HLT | Terminate the program |
Output
Address | Data |
---|---|
. . . | . . . |
8000 | 34 |
8001 | CD |
. . . | . . . |
- Related Articles
- 8085 program to swap two 16-bit numbers using Direct addressing mode
- 8085 program to swap two 8-bit numbers
- 8085 Program to Add two 8 Bit numbers
- 8085 Program to Subtract two 8 Bit numbers
- 8085 Program to Divide two 8 Bit numbers
- 8085 program to multiply two 8 bit numbers
- 8085 program to multiply two 8 bit numbers using logical instructions
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find maximum of two 8 bit numbers
- Program to Add two 8 Bit numbers in 8085 Microprocessor
- Program to Subtract two 8 Bit numbers in 8085 Microprocessor
- Program to Divide two 8 Bit numbers in 8085 Microprocessor
- 8085 program to sum of two 8 bit numbers without carry
- 8085 program to subtract two 8-bit numbers with or without borrow
- 8085 Program to multiply two 8-bit numbers (shift and add method)

Advertisements