0% found this document useful (0 votes)
68 views

Experiment No. 04: DATA DW 2FDH, 6D6AH, 17CAH, 5134H

The document describes three assembly language experiments involving numeric operations: 1) Writing a program to calculate the sum of numbers in an array. 2) Writing a program to perform multiplication and division operations to calculate the result of a formula. 3) Writing a program to use shift instructions to perform multiplication and division on two arrays, storing results in two output arrays.

Uploaded by

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

Experiment No. 04: DATA DW 2FDH, 6D6AH, 17CAH, 5134H

The document describes three assembly language experiments involving numeric operations: 1) Writing a program to calculate the sum of numbers in an array. 2) Writing a program to perform multiplication and division operations to calculate the result of a formula. 3) Writing a program to use shift instructions to perform multiplication and division on two arrays, storing results in two output arrays.

Uploaded by

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

Experiment No.

04
Objective: Learning how to manipulate with sequence of numbers in assembly
language. Full assembly language program involving addition, multiplication and
division will be reviewed in this lab.

LAB Work:
A. Write an assembly program that finds the sum of the following array of
numbers:
DATA DW 2FDH,6D6AH,17CAH,5134H.

.MODEL SMALL
.STACK 64H
.DATA
DATA DW 2FDH,6D6AH,17CAH,5134H
ORG 10H
SUM DW ?

.CODE
MAIN: MOV AX,@DATA
MOV DS,AX
MOV CX,04
MOV DI,OFFSET DATA
MOV BX,00
ALOOP: ADD BX,[DI]
INC DI
INC DI
DEC CX
JNZ ALOOP
MOV SI,OFFSET SUM
MOV [SI],BX
MOV AH,4CH
INT 21H
END MAIN
B. Students will learn how to write a program that finds the result of following
formula, understanding the concept of multiplication and division operations in
assembly.
Assume that X=3, Y=4, Z=6 , Result will be saved in Q (integer division) and R
(remainder).
.MODEL SMALL
.STACK 64H
.DATA
X DB 3
Y DB 4
Z DB 6
ORG 10H
Q DB ?
R DB ?
.CODE
MAIN: MOV AX,@DATA
MOV DS,AX
MOV AL,X
ADD AL,Y
MUL Z
MOV BL,3
DIV BL
MOV Q,AL
MOV R,AH
MOV AH,4CH
INT 21H
END MAIN

C. Shift instructions can be used to multiply and divide unsigned numbers.


Given the following two arrays (A and B), write an assembly language program
to perform the necessary operations to calculate the values in arrays C and D.
Use suitable shift instructions to perform the multiplication and division
operations.

A= 46, 37, 77, 94, 64, 59


B= 2, 4, 8, 16, 32, 64

Ci  Ai Bi
i  1,  , 6
Di  Ai / Bi
.MODEL SMALL
.STACK 64
.DATA
A DB 46, 37, 77, 94, 64, 59
B DB 2, 4, 8, 16, 32, 64
C DW 6 DUP(?)
D DB 6 DUP(?)
.CODE
MAIN: MOV AX,@DATA
MOV DS,AX
MOV CH,6
MOV CL,1
MOV SI, OFFSET A
MOV BX, OFFSET C
MOV DI, OFFSET D
BACK: MOV AH,00
MOV AL,[SI]
SHL AX,CL
MOV [BX],AX ; save the multiplication
MOV AL,[SI]
SHR AL,CL
MOV [DI],AL ; save the division (ignore remainder)
INC SI
INC BX
INC BX
INC DI
INC CL
DEC CH
JNZ BACK
MOV AH,4CH
INT 21H
END MAIN

H.W. 3 (deadline: next lesson)


1. Write a program that finds the result of the following formula. Check the
program for the given value and write down your obtained results as well.

X1= 3, X2=6, X3=9


2. Assume that the following two arrays (X and Y) are given.
X= 15, 24, 17, 12, 14, 23, 11, 22, 16, 12

Y= 12, 23, 28, 19, 15, 19, 25, 18, 26, 21

Write a program that calculates Z according to the mathematical formula


N

given below: Z   X i  Yi , ( N  1,...,10)


i 1

You might also like