Experiment No. 04: DATA DW 2FDH, 6D6AH, 17CAH, 5134H
Experiment No. 04: DATA DW 2FDH, 6D6AH, 17CAH, 5134H
Experiment No. 04: DATA DW 2FDH, 6D6AH, 17CAH, 5134H
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
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