0% found this document useful (0 votes)
47 views7 pages

Experiment No: 03 Experiment Name: XCHG, Conditional & Unconditional Jump and If-Else Statement in Assembly Language. Requirements

The document discusses an experiment involving assembly language instructions for exchanging registers (XCHG), conditional jumps, and unconditional jumps. It provides code examples to swap values in registers using XCHG and test a number to branch to different code based on its value using conditional jumps. The objectives are to learn basic assembly syntax and executing code in EMU8086.

Uploaded by

zibran Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views7 pages

Experiment No: 03 Experiment Name: XCHG, Conditional & Unconditional Jump and If-Else Statement in Assembly Language. Requirements

The document discusses an experiment involving assembly language instructions for exchanging registers (XCHG), conditional jumps, and unconditional jumps. It provides code examples to swap values in registers using XCHG and test a number to branch to different code based on its value using conditional jumps. The objectives are to learn basic assembly syntax and executing code in EMU8086.

Uploaded by

zibran Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Experiment No: 03

Experiment Name: XCHG, Conditional & Unconditional jump and If-Else


Statement in Assembly Language.
Requirements:
⦁ PC/Laptop

⦁ EMU8086 software

Objectives:
⦁ To familiar with the basic syntax of assembly language.

⦁ To learn how to implement and execute assembly code in EMU8086.

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

Conditional & Unconditional Jump:


In Assembly language, a jump instruction is used to transfer control of the program from one part
of the code to another. Jump instructions can be conditional or unconditional. An unconditional
jump instruction unconditionally transfers control to another location in the program. It simply
tells
the processor to jump to another location and continue executing instructions from there, without
any condition being tested. Examples of unconditional jump instructions include JMP, CALL,
and
RET. A conditional jump instruction transfers control to another location in the program only if a
particular condition is met. In other words, it tests a flag or register and based on its value
decides
whether or not to execute the jump. Conditional jumps are typically used for making decisions in
the program flow, such as branching to different parts of the code based on user input or the
results of a calculation. Examples of conditional jump instructions include JE (Jump If Equal),
JNE
(Jump If Not Equal), JZ (Jump If Zero), JNZ (Jump If Not Zero), and so on. The type of jump
instruction used in a program depends on the specific requirements of that program.
Unconditional
jumps are useful for implementing loops or branching to subroutines, while conditional jumps
are
2
useful for implementing decision-making logic in the code. Both types of jump instructions are
critical for creating complex programs in Assembly language.

Source Code and Output:


Task1: Take a number and check it if the number is >=100 or >=80 or >=60 or>=40
Or >=20, and if less than 20 then print the number is less than 20.

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.

You might also like