Problem – Write an assembly language program to swap two 8-bit numbers stored in 8085 microprocessor.
Assumption – Suppose there are two 8-bit numbers. One 8-bit number is stored at location 2500 memory address and another is stored at location 2501 memory address. Let 05 is stored at location 2500 and 06 is stored at location 2501 (not necessarily, can be any two 8-bit numbers).
- Load accumulator with the content of any one location (either 2500 or 2501 or any given location).
- Move the contents of accumulator to any register (say B) so that another location’s content can be loaded to accumulator and the previous data of accumulator get saved in register.
- Store the content of accumulator to another location (data of 2501 to 2500).
- Load accumulator with content of register and then store it to another address location.
|200E||HLT||Terminates the program|
- LDA 2500 – Load accumulator with content of location 2500
- MOV B,A – Copy content of accumulator to register B
- LDA 2501 – Load accumulator with content of location 2501
- STA 2500 – Store content of accumulator to location 2500
- MOV A,B – Copy content of register B to accumulator
- STA 2501 – Store content of accumulator to location 2501
- HLT – Terminates the program