Problem – Write a program to swap two 16-bit numbers using direct addressing mode where starting address is 2000 and the first 16-bit number is stored at 3000 and the second 16-bit number is stored at 3002 memory address.
- Load a 16-bit number from memory 3000 into a register pair (H-L)
- Exchange the register pairs
- Load a 16-bit number from memory 3002 into a register pair (H-L)
- Exchange both the register pairs
|2000||LHLD||||[H-L] <- |
|2004||LHLD||||[H-L] <- |
Explanation – Registers (H-L) pair, (D-E) pair are used for general purpose.
- LHLD is used to load register pair H-L direct using 16-bit address (3 Byte instruction)
- XCHG is used to exchange the data of both the register pair (H-L), (D-E) (1 Byte instruction)
- HLT is used to halt the program.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- 8085 program to swap two 8 bit numbers using Direct addressing mode
- 8085 program to swap two 8-bit numbers
- Difference between Direct and Immediate Addressing Modes
- Difference between Direct and Indirect Addressing Modes
- Addressing modes in 8085 microprocessor
- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to count total odd numbers in series of 10 numbers
- 8085 program to add 2-BCD numbers
- 8085 program to add two 8 bit numbers
- 8085 program to add two 16 bit numbers
- 8085 program to multiply two 16-bit numbers
- 8085 program to divide two 8 bit numbers
- 8085 program to add numbers in an array
- 8085 program to multiply two 8 bit numbers
- 8085 program to divide two 16 bit numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.