×

Embedded Systems Tutorial

AVR Microcontroller

8051 Microcontroller

8085 Microprocessor

8086 Microprocessor

8255 Microprocessor

Embedded Systems Practice

Swap Two 16-bit Numbers using Direct Addressing Mode

In this tutorial, we will learn how to swap two 16-bit numbers using direct addressing mode in 8085 Microprocessor? By Akash Kumar Last updated : May 13, 2023

Swap Two 16-bit Numbers using Direct Addressing Mode in 8085 Microprocessor

Given two 16-bits numbers, we have to swap them using direct addressing mode in 8085 Microprocessor.

Algorithm

  1. Load the first 16bit number in HL pair register.
  2. Exchange the content of HL pair with DE register.
  3. Now load the second 16bit number in HL pair register.
  4. Exchange the content of HL pair register with DE register.
  5. Now store the content of HL pair at memory location of first number.
  6. Exchange the content of HL pair register with DE register.
  7. Now store the content of HL pair at memory location of second number.
  8. Terminate the program.

Program

LHLD 2050
XCHG
LHLD 2052	
XCHG
SHLD 2050
XCHG
SHLD 2052
HLT

Observation

INPUT: 
2050:07
2051:04
2052:05
2053:06

OUTPUT: 
2050:05
2051:06
2052:07
2053:04

Hence we successfully swapped two 16 bits numbers using direct addressing mode on 8085 microprocessor.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.