Question
Write and run a program using 8086 assembly language that interchanges the values stored in two memory locations. Make suitable assumptions, if any.
Answer :
Word Count : 903
___ ______ __________ ___ ________ _______ ______ _____.
_______ ___ ________ _______ _______ _______ _____ ______ ____.
________ ____ _____ __________ _______.
____ ______ ____ ____ _________ ____ __________ __________ _____ ______ ____ ____.
_______ ______ ___ _______ ______ __________ _________ _____ __________ ______ ____ ________.
_______ ____ _______ _________ ____ ________.
________ _________ _______ _____ ________ __________.
_________ _______ ____ ____ ____ ____ _____ _____ ______ _______ ____ ___.
__________ ________ __________ ___ ________ ____ __________ ________ ___.
__________ ____ ______ ____ _______ ______ ____ __________ ___ ________ __________.
_______ _____ _______ _____ _____ _________ ___ ______ ___.
_____ _____ ________ _______ ____ ___ ______ _____ _________ ___ _________.
______ ____ ____ _________ ___ __________ ________ _______ _________.
________ ________ __________ ________ ___ ________ __________ ________ _________ _________ ________ __________.
____ ____ _______ ____ _________ ______ __________ _____ __________ _____ _______.
______ ___ ____ ______ ________ _______ __________ ___ ___ _________ _____ _________.
____ ________ ____ _________ ___ ________ ___.
_______ ___ _____ ________ ____ ____ __________ ______.
______ _____ __________ _____ _______.
_______ ________ ____ _________ __________ _____.
___ _________ ______ ______ __________ __________ _________ ________ ______ ____ _________ ____.
___ _________ __________ _________ ___.
_____ ____ _____ _______ ____ ________ ______ ____ __________ ______.
_______ ______ __________ ________ __________ _________ _______ _________ ______ __________ _______ _________.
_____ ______ _______ ___ ________ _______ ____ _________.
__________ __________ _________ _________ _________ _________ ___ ____.
___ ___ ________ ____ ________.
____ _______ ____ _______ ___ __________ __________.
___ _________ ________ ________ ___ _______ _________ _______ _________.
____ ____ ____ __________ ___ _________.
__________ _______ _______ __________ _____ __________ __________ ______.
__________ _______ ___ ___ ___ _____ ________ _______ _________ ________.
______ __________ _______ _________ ___ ________ ______ ___ _________ _______ ________ _______.
_________ ________ ________ ________ ________ ______.
________ ___ _____ __________ ___ __________ __________ _________.
___ ________ __________ _____ _____.
__________ _________ _________ ____ __________ _______ _________ ____ _________.
__________ __________ _________ ______ _____ _______ ___ _____ ______ ________ ______.
_______ ___ ___ _______ ________ ________ ________ __________ _____.
___ _________ _____ ____ ______ _________.
_______ ____ _____ ___ __________ _______ _______.
_____ ________ _______ _________ _____ _____.
_____ ___ ___ __________ __________ __________ _____.
___ _____ _________ ______ __________ __________ __________ __________ ___ ________ _____.
_________ ________ _________ __________ ________ ______.
___ __________ ______ _______ ____ _________ __________ _________.
__________ ___ _________ _____ ________ ______.
_________ ___ _______ _______ ______.
_______ ________ ____ ___ _______ ____ ____ _________ __________ _____.
___ _______ _________ ________ ____ ________ ___ __________ ____ __________ _________.
_________ ____ __________ _____ ________ _________ ____ ________ ______ ___ ______.
______ ______ _________ ____ ______.
_________ _____ __________ ____ ________ ___ __________ _______ ____.
____ _______ _________ ________ ____ _____ ___ __________ ____.
__________ ______ ________ _________ _______ _________ _____ ______ ______ __________.
__________ _________ ____ ________ ___ ________ _______ ____ ______ ____.
______ ________ _________ ______ _____ __________ ___ __________ ______ ____ _________ ___.
____ _____ _______ __________ ____ ___ _____ __________ ___ ___.
______ ___ ________ ____ ___ ____ _______ ____.
__________ ____ __________ _____ _________.
________ _____ _____ _____ _____ _____ ____ ______ ____ ________ ____.
________ ____ ________ ___ __________.
________ __________ ______ _________ __________ _____ _______ __________ ______ ____ ____.
____.
Skip in 10
In Assembly Language Programming, particularly with the 8086 microprocessor, exchanging values between two memory locations is a fundamental operation that demonstrates the understanding of memory addressing, data movement instructions, and basic arithmetic or logical operations. The 8086 microprocessor uses a segmented memory model, meaning memory is accessed through a combination of segment and offset addresses. For this exercise, it is assumed that the memory locations are in the data segment, and the values to be interchanged are bytes or words. This example will consider word-sized data, but the logic can easily be adapted for bytes. To begin with, the 8086 assembly language program requires initialization of the data segment register (DS) to point to the segment where our variables reside. Two memory locations, named `LOC1` and `LOC2`, are defined in the data segment with initial values. The task is to interchange these values without using high-level language constructs, relying solely on the instructions provided by the 8086 instruction set. A commonly used approach for interchanging values in memory is to use a temporary register as a buffer. In the 8086 architecture, registers such as AX, BX, CX, and DX are general-purpose registers suitable for temporary storage. The program can load the value from the first memory location into AX, then move the value from the second memory location into the first location, and finally move the original value from AX into the second memory location. This ensures that the original value of LOC1 is preserved while overwriting LOC2. The program begins with the declaration of the data segment, where `LOC1` and `LOC2` are initialized with arbitrary values for demonstration purposes. For example, `LOC1` can be initialized with `1234H` and `LOC2` with `5678H`. These values are stored as words, meaning each occupies two bytes in memory. The code segment starts with setting up the DS register to point to the data segment, ensuring that subsequent memory accesses refer to the correct segment. The instructions to interchange values are straightforward. First, the value from `LOC1` is loaded into the AX register using the `MOV AX, LOC1` instruction. This effectively stores the value of `LOC1`
______ _______ _________ ___ ______ _____ ___ ____ ____ ___ ______.___ ______ __________ ___ ________ _______ ______ _____.
_______ ___ ________ _______ _______ _______ _____ ______ ____.
________ ____ _____ __________ _______.
____ ______ ____ ____ _________ ____ __________ __________ _____ ______ ____ ____.
_______ ______ ___ _______ ______ __________ _________ _____ __________ ______ ____ ________.
_______ ____ _______ _________ ____ ________.
________ _________ _______ _____ ________ __________.
_________ _______ ____ ____ ____ ____ _____ _____ ______ _______ ____ ___.
__________ ________ __________ ___ ________ ____ __________ ________ ___.
__________ ____ ______ ____ _______ ______ ____ __________ ___ ________ __________.
_______ _____ _______ _____ _____ _________ ___ ______ ___.
_____ _____ ________ _______ ____ ___ ______ _____ _________ ___ _________.
______ ____ ____ _________ ___ __________ ________ _______ _________.
________ ________ __________ ________ ___ ________ __________ ________ _________ _________ ________ __________.
____ ____ _______ ____ _________ ______ __________ _____ __________ _____ _______.
______ ___ ____ ______ ________ _______ __________ ___ ___ _________ _____ _________.
____ ________ ____ _________ ___ ________ ___.
_______ ___ _____ ________ ____ ____ __________ ______.
______ _____ __________ _____ _______.
_______ ________ ____ _________ __________ _____.
___ _________ ______ ______ __________ __________ _________ ________ ______ ____ _________ ____.
___ _________ __________ _________ ___.
_____ ____ _____ _______ ____ ________ ______ ____ __________ ______.
_______ ______ __________ ________ __________ _________ _______ _________ ______ __________ _______ _________.
_____ ______ _______ ___ ________ _______ ____ _________.
__________ __________ _________ _________ _________ _________ ___ ____.
___ ___ ________ ____ ________.
____ _______ ____ _______ ___ __________ __________.
___ _________ ________ ________ ___ _______ _________ _______ _________.
____ ____ ____ __________ ___ _________.
__________ _______ _______ __________ _____ __________ __________ ______.
__________ _______ ___ ___ ___ _____ ________ _______ _________ ________.
______ __________ _______ _________ ___ ________ ______ ___ _________ _______ ________ _______.
_________ ________ ________ ________ ________ ______.
________ ___ _____ __________ ___ __________ __________ _________.
___ ________ __________ _____ _____.
__________ _________ _________ ____ __________ _______ _________ ____ _________.
__________ __________ _________ ______ _____ _______ ___ _____ ______ ________ ______.
_______ ___ ___ _______ ________ ________ ________ __________ _____.
___ _________ _____ ____ ______ _________.
_______ ____ _____ ___ __________ _______ _______.
_____ ________ _______ _________ _____ _____.
_____ ___ ___ __________ __________ __________ _____.
___ _____ _________ ______ __________ __________ __________ __________ ___ ________ _____.
_________ ________ _________ __________ ________ ______.
___ __________ ______ _______ ____ _________ __________ _________.
__________ ___ _________ _____ ________ ______.
_________ ___ _______ _______ ______.
_______ ________ ____ ___ _______ ____ ____ _________ __________ _____.
___ _______ _________ ________ ____ ________ ___ __________ ____ __________ _________.
_________ ____ __________ _____ ________ _________ ____ ________ ______ ___ ______.
______ ______ _________ ____ ______.
_________ _____ __________ ____ ________ ___ __________ _______ ____.
____ _______ _________ ________ ____ _____ ___ __________ ____.
__________ ______ ________ _________ _______ _________ _____ ______ ______ __________.
__________ _________ ____ ________ ___ ________ _______ ____ ______ ____.
______ ________ _________ ______ _____ __________ ___ __________ ______ ____ _________ ___.
____ _____ _______ __________ ____ ___ _____ __________ ___ ___.
______ ___ ________ ____ ___ ____ _______ ____.
__________ ____ __________ _____ _________.
________ _____ _____ _____ _____ _____ ____ ______ ____ ________ ____.
________ ____ ________ ___ __________.
________ __________ ______ _________ __________ _____ _______ __________ ______ ____ ____.
____.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.