Assembler Directives and Basic Steps of ALP: Dr. Urvashi Singh
Assembler Directives and Basic Steps of ALP: Dr. Urvashi Singh
CONSTANT: these are symbols whose values can not be varies while running a
program
A numeric constant may be a binary, decimal or hexadecimal number.
Symbols B, D & H must be used at the end of a binary, decimal and hexadecimal number,
respectively.
Important Assembler Directives of the 8086
Microprocessor
DQ (DEFINE QUADWORD)
The DQ directive is used to tell the assembler to declare a variable 4 words
in length or to reserve 4 words of storage in memory.
Example:
BIG_NUMBER DQ 243598740192A92BH; This will declare a variable named
BIG_NUMBER and initialize the 4 words set aside with the specified number when the
program is loaded into memory to be run.
Example:
ASSUME CS:CODE ;This tells the assembler that the logical
segment named CODE contains the instruction statements for
the program and should be treated as a code segment.
ORG Changes the starting offset address of the data in the data
segment. As an assembler assembles a section of a data declarations
or instruction statements, it uses a location counter to keep track of
how many bytes it is from the start of a segment at any time.
The ORG directive allows you to set the location counter to a desired
value at any point in the program.
Example:
The statement ORG 2000H tells the assembler to set the location counter to
2000H.
SEGMENT
EXTRN : used to tell the assembler that the name or labels following the
directive are in some other assembly module.
For example, if you want to call a procedure, which in a program module assembled at a
different time from that which contains the CALL instruction, you must tell the assembler
that the procedure is external. The assembler will then put this information in the object
code file so that the linker can connect the two modules together.
For a reference to externally named variable, you must specify the type of the variable, as in
the statement EXTRN DIVISOR: WORD. The statement EXTRN DIVIDE: FAR tells the
assembler that DIVIDE is a label of type FAR in another assembler module. Name or labels
referred to as external in one module must be declared public with the PUBLIC directive in
the module in which they are defined.
PUBLIC - The PUBLIC directive is used to instruct the assembler that a
specified name or label will be accessed from other modules.
Example:
PUBLIC DIVISOR, DIVIDEND ;these two variables are public so these are available to all
modules. If an instruction in a module refers to a variable in another assembly module, we
can access that module by declaring as EXTRN directive.
TYPE, PTR(POINTER)
INC BYTE PTR [BX] ; This statement tells the assembler that we want to increment the
byte pointed to by BX.
INC WORD PTR [BX] ; This statement tells the assembler that we want to increment the
word pointed to by BX. The PTR operator assigns the type specified before PTR to the
variable specified after PTR.
LENGTH, OFFSET
NAME : used to give a specific name to each assembly module when programs consisting of
several modules are written.
LABEL : As an assembler assembles a section of a data declarations or instruction statements,
it uses a location counter to be keep track of how many bytes it is from the start of a segment at
any time.
If the label is going to be used as the destination for a jump or a call, then the label must be
specified as type near or type far.
SHORT
The SHORT operator is used to tell the assembler that only a 1 byte displacement is
needed to code a jump instruction in the program. The destination must in the range of –
128 bytes to +127 bytes from the address of the instruction after the jump.
Example: JMP SHORT NEARBY_LABEL