COAL LAB Manual 2 FAST NUCES

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

National University of Computer and Emerging Sciences

Laboratory Manual

for
Computer Organization and Assembly Language Programming

Page 1 of 2
Objectives
After performing this lab, students shall be able to:

✔ Learn different data types.


✔ Declare and use variables in assembly language.

Data Types
Variables are declared in memory.

DB Define Byte allocates 1 byte (0 – (28 – 1))

DW Define Word allocates 2 bytes (0 – (216 – 1))

DD Define Doubleword allocates 4 bytes (0 – (232 – 1))

DQ Define Quadword allocates 8 bytes (0 – (264 – 1))

DT Define Ten Bytes allocates 10 bytes (0 – (280 – 1))

Example:
; a program to add three numbers using memory
variables [org 0x0100]

mov ax, [num1] ;load first number in ax


mov bx, [num2] ; load second number in bx
add ax, bx ; accumulate sum in ax
mov [result1], ax ; store result in result1 variable, 15

mov ax, 0x4c00 ; terminate


int 0x21 program

num1: dw 5 ;variables
num2: dw 10

result1: dw

Page 2 of 4
Exercise 1: Write a program that swaps the value of two registers using a data label i.e.
given these initial values: ax=100, bx=200. After rotation, ax=200, bx=100.

Exercise 2: Develop an assembly program that reads 1 number each from 5 different data
labels to a register and stores their sum in some other memory location labeled as result.

Exercise 3: Move a number (6 for this question) from a memory location in AX, move 4 into
BX then find num * 4 using ADD instruction and then divide that answer by 3 using SUB
instruction. Store the results of multiplication and division (quotient) at different memory
locations labeled as “mresult” and “dresult”.

Exercise 4: Write a program to generate first 10 terms of the Fibonacci Series. The
generated terms are to be placed at memory location named “Fib” using indirect addressing

Page 3 of 4

You might also like