Professional Documents
Culture Documents
Objective(s):
Upon completion of this lab session, learners will be able to:
1. In this lab, students will learn how I/O operations, basic interrupts and service routines and
arithmetic expressions.
Lab Tasks:
Task 1: Write a program to declare two variable A and B set their values to be 5,7 add them and store
their result in BX register.
CODE:
.MODEL SMALL
.STACK 100H
.DATA
A DW 5
B DW 7
.CODE
MAIN PROC
MOV AX, @DATA ; Load data segment address into AX
MOV DS, AX ; Set data segment to data segment address
1
Computer Organization and Assembly Language-Lab Instructor: Munaza Sher
MOV BX, B
END MAIN
OUTPUT:
2
Computer Organization and Assembly Language-Lab Instructor: Munaza Sher
Task 2: Write the assembly code for following: A = B – 2 x A using add and sub instructions.
CODE:
.model small
.stack 100h
.data
a dw 5
b dw 7
.code
main proc
mov ax, @data
mov ds, ax
mov ax, b
mov bx, 2
add ax, ax
sub ax, bx
mov a, ax
OUTPUT:
Task 3: Convert A=-(A+1) in assembly code using increment, negate and move instruction.
CODE:
.model small
.stack 100h
3
Computer Organization and Assembly Language-Lab Instructor: Munaza Sher
.data
A db 5 ; Variable A initialized with value 5
.code
main proc
mov ax, @data
mov ds, ax
; Load A into AL
mov al, A
; Increment AL by 1 (A + 1)
inc al
CODE:
.model small
.stack 100h
.data
4
Computer Organization and Assembly Language-Lab Instructor: Munaza Sher
.code
main proc
mov ds, ax
; Load A into AL
mov al, A
; Load B into BL
mov bl, B
; Negate AL (-A)
neg al
; Add BL to AL (B - A)
add al, bl
mov A, al
int 21h
main endp
end main
Max Obtained
Task Comments(if any)
Marks Marks
1. 01
2. 03
3. 03
4. 03
Total 10 Signature
Note : Attempt all tasks and get them checked by your Lab Instruct
6
Computer Organization and Assembly Language-Lab Instructor: Munaza
Sher