You are on page 1of 7

Computer Organization and Assembly Language-Lab Instructor: Munaza Sher

Bahria University, Lahore Campus


Department of Computer Science
Lab Journal 04
(Spring 2024)

Computer Organization and Assembly Language-


Course: Lab Date: _______________
Course Code: CEL 325 Max Marks: 10
Faculty’s Name: Munaza Sher

Name: ________M. Ahmed_____________ Enroll No: _____03-134231-034______________ Class:


____BSCS 3__________

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

; Load values of A and B into registers


MOV AX, A

1
Computer Organization and Assembly Language-Lab Instructor: Munaza Sher

MOV BX, B

; Add the values of A and B


ADD AX, BX

; Store the result in BX register


MOV BX, AX

; Terminate the program


MOV AH, 4CH ; Set AH to 4CH (exit code)
INT 21H ; Call DOS interrupt to exit the program
MAIN ENDP

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

mov ax, 4c00h


int 21h
main endp
end main

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

; Negate AL (-(A + 1))


neg al

; Store the result back in A


mov A, al

; Exit the program


mov ax, 4c00h
int 21h
main endp
end main

Task 4: Convert A=B-A in assembly code using negate and add.

CODE:
.model small

.stack 100h

.data

A db 5 ; Variable A initialized with value 5

B db 7 ; Variable B initialized with value 7

4
Computer Organization and Assembly Language-Lab Instructor: Munaza Sher

.code

main proc

mov ax, @data

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

; Store the result back in A

mov A, al

; Exit the program

mov ax, 4c00h


5
Computer Organization and Assembly Language-Lab Instructor: Munaza Sher

int 21h

main endp

end main

Lab Grading Sheet :

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

You might also like