Practical Lab 8
Practical Lab 8
Practical no#08
Introduction:
In this experiment you will be introduced to data transfer and arithmetic instructions.
You will also deal with indexing, and array manipulation.
Objectives:
The ASCII table is a double entry table, which contains all alphanumeric characters
and symbols. Each symbol, or character, has its own ASCII code. This code can either
be in decimal or hexadecimal format. The code of a given character is found by
concatenating the column number with the row number, if the code is to be expressed
in hexadecimal. The row number is to be the least significant. For the same code to be
expressed in decimal, the row number is added to the column number (See example
given below).
The following tables show the ASCII codes (Table 8.1), and examples on the use of
the ASCII table (Table 8.2), and how to calculate the ASCII codes for different
characters and symbols.
Table 8.1: 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 practical no.07).
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
Remark:
Notice that row R, has index (R-1), and element n has index (n-1).
Pre Lab Work:
1. Study programs 8.1 and 8.2, and review the material related to indexing
and data manipulation.
2. Write both programs and see how program 8.1 manipulates the variables in
internal registers, and how program 8.2 uses memory for the same purpose.
Lab Work:
.
1- How many digits can you enter each time? Explain this.
2- What happens when the sum exceeds 9? Explain this.
Lab Assignment:
Write a program that prompts the user to enter a number Then the program checks
whether the entered number is Prime number or not?
TITLE "PROGRAM 1 EXPERIMENT 8"
.MODEL SMALL
.STACK 200
.DATA
CRLF DB 0DH,0AH,'$'
PROMPT1 DB 'Enter the first positive integer: ','$'
PROMPT2 DB 'Enter the second positive integer: ','$'
PROMPT3 DB 'The sum of the two numbers is: ','$'
.CODE
.STARTUP
LEA DX,PROMPT1 ;DISPLAY PROMPT1
MOV AH,09H
INT 21H
MOV CL,AL
ADD CL,30H ;CONVERT DIGIT TO CHARACTER