Lab Report 2
Lab Report 2
Lab Report: 02
Class: COMP-261L
Name: Jamal Ahmed Khan
Registration No.: B20F0358CS022
Semester: 3rd
Submitted to: Sir Rafiullah
__________________
Instructor Signature
Lab No. 02
Objectives:
Understand the working and use of MOV instruction.
Understand the working and use of XCHG instruction.
Tools/Software Required:
EMU 8086 Tool
:Introduction
Pronounced as ‘exchange’, XCHG swaps the contents of its operands. Operand can both be
.registers or a register and a memory location
Lab Tasks:
Lab Task 01: Write a set of instructions in 8086-88 assembly language that swaps the contents of
CX and DX registers without using XCHG instruction.
Code:
.Model small
.stack 100h
.data
msg db "AB",0dh,0ah,'&'
.code //Code Start
main proc
mov cx,111 //move value into CX register
mov dx,222 //move value into DX register
mov ax,cx //move cx into ax temp
mov cx,dx //mov dx into cx
mov dx,ax //move ax into dx
main endp
end main
Output:
Task 2
Write a set of instructions in 8086-88 assembly language that swaps the contents of SS and DS
registers.
Code:
.model small
.stack 100h
.data
msg db "AB",0dh,0ah,'&'
.code
main proc
mov bx,111
mov ds,bx
mov bx,222
mov ss,bx
mov cx,ds
mov ds,bx
mov bx,ss
main endp
end main
Output:
Task 3:
Code:
.model small
.stack 100h
.data
.code
main proc
mov ax,9FFFH
main endp
endp main
Output:
Task 4
Write a set of instructions in 8086-88 assembly language that swaps the contents of upper and
lower bytes in BX register without using XCHG instruction.
Code:
.model small
.stack 100h
.code
main proc
mov ax,9fffh
mov bl,al
mov al,ah
mov ah,bl
main endp
end main
Output: