Lab Manual 4 (1)
Lab Manual 4 (1)
Information Technology
Lab # 04
A directive is a command embedded in the source code that is recognized and acted upon by the
assembler. Directives do not execute at runtime. Directives can define variables, macros, and
procedures. They can assign names to memory segments and perform many other housekeeping
tasks related to the assemble or assembler directive is a message to the assembler that tells the
assembler something it needs to know in order to carry out the assembly process; for example, an
assemble directive tells the assembler where a program is to be located in memory.
Data Declarations:
The default number system used by the assembler is decimal. Using other number systems
entail appropriate suffixes as shown below:
Binary B
Hexadecimal H
Octal O or Q
Decimal None
Table 1
A hexadecimal value must start with a digit. For example, code 0a8h rather than a8h to get
a constant with value A816. The assembler will interpret a8h as a name.
Some Assembler Directives:
DB
define byte
DW define word
DT
define ten bytes (five consecutive words.
Computer Architecture & Organization Department of Computer Science &
Information Technology
Byte Variables
Assembler directive format assigning a byte variable
Name DB initial value
Other data type variables have the same format for defining the variables like:
Name DW initial value
Named Constants
LF EQU 0AH
o MOV DL, 0AH
o MOV DL, LF
PROMPT EQU "Type your name"
o MDC DB PROMPT
Integer Constants
An integer constant (or integer literal) is made up of an optional leading sign, one or more
digits, and an optional suffix character (called a radix ) indicating the number‟s base:
Radix may be one of the following (uppercase or lowercase), If no radix is given, the
integer constant is assumed to be decimal. (Refer table 1 for radix examples)
Computer Architecture & Organization Department of Computer Science &
Information Technology
Character Constants
String Constants
Reserved Words
Reserved words have special meaning in Assembler and can only be used in their correct context.
There are different types of reserved words:
Identifiers
P-1
Computer Architecture & Organization Department of Computer Science &
Information Technology
Computer Architecture & Organization Department of Computer Science &
Information Technology
EXERCISE:
Q1. Refer to p-1, assemble the program and examine the listing file. Determine the opcode
and size of each instruction inside the main procedure.
Computer Architecture & Organization Department of Computer Science &
Information Technology
Q2. Refer to p-1, examine the listing file and determine how many bytes reserved by each
constant/ variable also determine the address range occupied by each variable.
Q3. Find the values that the assembler will generate for each of the directives below. Write
your answer using two hex digits for each byte generated.
Q4. Write an assembly language program to swap numbers stored at value1 and value2.
Assume value1 is last-digit-of-roll# and value2 is second-last-digit-of-your-roll
Computer Architecture & Organization Department of Computer Science &
Information Technology