Lab Experiment # 4: Objectives
Lab Experiment # 4: Objectives
Objectives:
As an example, the symbol’ $’ is at the intersection of row 4 and column 2, therefore its
ASCII code is 24H. The decimal equivalent of this code can be found by adding 4 to 32,
which yields 36.
The following tables show the ASCII codes (Table 4.1), and examples on the use of the
ASCII table (Table 4.2), and how to calculate the ASCII codes for different characters
and symbols.
Table 4.1: ASCII Table
a 6 1 61 96+1=97
A 4 1 41 64 + 1 = 65
β E 1 E1 224 + 1 = 225
% 2 5 25 32 + 5 = 37
Table 4.2: Examples on the use of the ASCII table
The DB and DW directives are respectively used to declare a variable of size byte or
word. The following declaration defines a variable X of size byte and assigns it the value
10H.
X DB 10H
Identically the following will define a variable of size word, and assigns it the value
13EFH: Y DW 13EFH
The DUP directive may be used to reserve more than one consecutive data item and
initialize reserved items to the same value. For example, the instruction:
Instructs the assembler to reserve an array of 100 bytes, and initializes each byte to the
value zero. If the “0” in the above declaration is replaced with “?”, the assembler will not
initialize the bytes of the array to any value.
To access the different elements of an array, we use one of the following addressing modes
(See Experiment # 3).
Array1 DB 0,1,2,3,4,5,6,7,8,9
Array2 DB 10 DUP(0)
Array3 DB 11,12,13,21,22,23,31,32,33
RowSize EQU 3
3. Modify program 4.1 so that it adds two numbers of two digits each. Use only registers,
and make sure to take care of the carry when adding the two most significant digits. Call
this program 4.3.
Note: In this case try to understand how the program reads the numbers and how it manipulates them. This
will help you in writing your program. As a hint, one should know that numbers are given in decimal to the
program.
4. Bring your work to the lab.
Lab Work:
1- Assemble, Link and Run program 1.
Program 1
.MODEL SMALL
.STACK 200
.DATA
CRLF DB 0DH,0AH,'$'
.CODE
.STARTUP
INT 21H
INT 21H
MOV DL,CL
MOV AH,02H
INT 21H
.EXIT
END
2- How many digits can you enter each time? Explain this.
. MODEL SMALL
.STACK 200
.DATA
CRLF DB 0DH,0AH,'$'
NUM1 DB ?
NUM2 DB ?
RES DB ?
.CODE
COAL Lab Manual
.STARTUP
INT 21H
MOV AH,09H
INT 21H
INT 21H
INT 21H
INT 21H
;DISPLAY SUM
.EXIT END
5. Repeat step 4 with program 3.
TITLE TWO_DIGIT_ADDITION
.MODEL SMALL
.STACK 100H
.DATA
DIGIT1 DB 0AH, 0DH, "ENTER FIRST DIGIT: $"
DIGIT2 DB 0AH, 0DH, "ENTER SECOND DIGIT: $"
RESULT DB 0AH, 0DH, "RESULT IS $"
.CODE
MAIN:
MOV AX, @DATA
MOV DS, AX
ADD BL, CL
MOV AL, BL
MOV AH, 00H
AAA
ADD BL, BH
ADD BL, CH
MOV AL, BL
MOV AH, 00H
AAA
MOV BX, AX
;MOV BH, AH
;MOV BL, AL
MOV DL, BH
ADD DL, 30H
MOV AH, 02H
INT 21H
MOV DL, BL
ADD DL, 30H
MOV AH, 02H
INT 21H
MOV DL, CL
ADD DL, 30H
MOV AH, 02H
INT 21H
EXIT:
MOV AH, 04CH
INT 21H
END MAIN
Lab Assignment
1. Write a program to check input number is even or odd.
2. Write a program in assembly language to find the
Square of a given number.
3. Write a program to print an array with loop
4. Write a program to print an array without loop
5. Explain the use of “DUP” in assembly language through a code.