8085 program to swap two 8 bit numbers using Direct addressing mode
Problem – Write a program to swap two 8-bit numbers using direct addressing mode where starting address is 2000 and the first 8-bit number is stored at 3000 and the second 8-bit number is stored at 3001 memory address.
Example –

Algorithm –
- Load a 8-bit number from memory 3000 into accumulator
- Move value of accumulator into register H
- Load a 8-bit number from memory 3001 into accumulator
- Move value of accumulator into register D
- Exchange both the register pairs
- Stop
Program –
| Memory | Mnemonics | Operands | Comment |
|---|---|---|---|
| 2000 | LDA | [3000] | [A] <- [3000] |
| 2003 | MOV | H, A | [H] <- [A] |
| 2004 | LDA | [3001] | [A] <- [3001] |
| 2007 | MOV | D, A | [D] <- [A] |
| 2008 | XCHG | [H-L] [D-E] | |
| 2009 | HLT | Stop |
Explanation – Registers A, H, D are used for general purpose.
- LDA is used to load accumulator direct using 16-bit address (3 Byte instruction)
- MOV is used to transfer the data (1 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.
Recommended Posts:
- 8085 program to swap two 16 bit numbers using Direct addressing mode
- 8085 program to swap two 8-bit numbers
- 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 two 16 bit numbers
- 8085 program to add 2-BCD numbers
- 8085 program to add two 8 bit numbers
- 8085 program to multiply two 8 bit numbers
- 8085 program to divide two 8 bit numbers
- 8085 program to sum of two 8 bit numbers without carry
- 8085 program to multiply two 16-bit numbers
- 8085 program to divide two 16 bit numbers
- 8085 program to add numbers in an array
- 8085 program to add three 16 bit numbers stored in registers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.



