Home »
Embedded Systems
Swap Two 8-bit Numbers using Direct Addressing Mode
In this tutorial, we will learn how to swap two 8-bit numbers using direct addressing mode in 8085 Microprocessor?
By Akash Kumar Last updated : May 14, 2023
Swap Two 8-bit Numbers using Direct Addressing Mode in 8085 Microprocessor
Write a program to swap two 8-bit numbers using direct addressing mode on 8085 microprocessor.
Algorithm
- Load first number to the accumulator.
- Move the first number to register H.
- Load second number to the accumulator.
- Move the second number to register D.
- Exchange the content both the register pair.
- Terminate the program.
Program
LDA 2050
MOV H, A
LDA 2051
MOV D, A
XCHG
HLT
Observation
INPUT:
2050:07
2051:04
OUTPUT:
2050: 04
2051: 07
Hence we successfully swapped two 8 bit number using direct addressing mode.