Experiment No: 03 Experiment Name: XCHG, Conditional & Unconditional Jump and If-Else Statement in Assembly Language. Requirements
Experiment No: 03 Experiment Name: XCHG, Conditional & Unconditional Jump and If-Else Statement in Assembly Language. Requirements
⦁ EMU8086 software
Objectives:
⦁ To familiar with the basic syntax of assembly language.
Theory:
XCHGKeyword:
In computer science, the XCHG (exchange) instruction is a low-level operation
commonly used in
assembly language and microcode. The XCHG instruction swaps the contents of two
operands,
which can be registers, memory locations, or combinations of both. The basic idea behind
the XCHG
instruction is to exchange the values of two variables without using an intermediate
variable. It is
often used in algorithms such as sorting and searching, where the order of elements needs
to be
changed. In modern processors, the XCHG instruction is typically implemented as a
single atomic
operation that does not require any additional synchronization or locking mechanisms.
This makes it
useful in multi-threaded programming environments, where concurrent access to shared
resources
must be carefully managed. The actual operation of the XCHG instruction depends on the
specific
processor architecture, but at a high level, it works by reading the values of the source and
destination operands, exchanging them, and then writing the exchanged values back to
their
respective locations. In some architectures, the XCHG instruction may also set one or
more flags in
the processor's status register to indicate whether the operation was successful or if any
errors
occurred. Overall, the XCHG instruction is a powerful tool for manipulating data at a low
level, and it
is widely used in system-level programming tasks where performance and efficiency are
1
critical
factors.
Code:
.model small
.stack 100h
.data
.code
main proc
mov bl,53
mov bh,55
xchg bl,bh
mov ah,2
mov dl,bl
int 21h
mov dl,0ah
int 21h
mov dl,0dh
int 21h
mov ah,2
mov dl,bh
int 21h
mov ah, 4ch
int 21h
main endp
end main
3
4
5
6
Discussion: In this lab,i learned about In 8085 Instruction set, there is one
mnemonic XCHG, which stands for eXCHanGe. This is an instruction to
exchange contents of HL register pair with DE register pair. This instruction
uses implied addressing mode.And i also make a operation about
conditional and unconditional jump.Transfers the program sequence to the
described memory address is called Unconditional Jump. Conditional Jump
Instructions Transfers the program sequence to the described memory
address only if the condition in satisfied.