Home »
Embedded Systems
Swap Two 8-bit Numbers in 8086 Microprocessor
In this tutorial, we will learn how to swap two 8-bit numbers in 8086 Microprocessor?
By Akash Kumar Last updated : May 22, 2023
Problem Statement
To swap two 8 bits numbers using third register on 8086 microprocessor.
Algorithm
- Load first number in register AL through memory.
- Move the content of register AL in register BL.
- Load the second number in register AL through memory.
- Store the content of register AL at the memory location of first number.
- Store the content of register AL at the memory location of second number.
- Terminate the program
Program
MOV AL, [0600]
MOV BL, AL
MOV AL, [0601]
MOV [0600], AL
MOV [0601], BL
HLT
Observation
INPUT:
0600:05
0601:04
OUTPUT:
0600:04
0601:05
Hence we successfully swapped two 8-bit using third register on 8086 microprocessor.