Home »
Embedded Systems
Exchange content of HL register pair with DE register pair
Here, we are going to learn how to exchange content of HL register pair with DE register pair in 8085 Microprocessor?
Submitted by Shivakshi Dhiman, on November 08, 2018
Problem statement:
To exchange the content of HL pair register with the content of DE register using 8085 Microprocessor
Assumption: The value is already present in both HL register and DE register.
Algorithm:
- Initialize the value of stack pointer (SP) by 3FFF
- Push the content of H and L register into the stack and decrease the value ofstack pointer by 2
- Push the content of D and E register into the stack and decrease the value of stack pointer by 2
- Pop the upper two bytes from top of stack and copy it to HL register and increase the value of stack pointer by 2
- Pop the upper two bytes from top of stack and copy it to DE register and increase the value of stack pointer by 2
- Terminate the program
Program:
LXI SP 3FFF
PUSH H
PUSH D
POP H
POP D
HLT
Observation:
INPUT:
H:04
L:05
D:12
E:24
OUTPUT:
H:12
L:24
D:04
E:05
Hence we successfully exchanged the content of register HL with the content of register DE.