Assembler Directives
Assembler Directives
of 8086
ASSEMBLER DIRECTIVES
● examples:
PRICES DB 49H, 98H, 29H; Declare array of 3 bytes
named PRICES and initialize them with specified
values
TEMP DB 100 DUP (?); Set aside 100 bytes of
storage in memory and give it the name TEMP. But
leave the 100 bytes un-initialized
Data declaration directives
● examples:
WORDS DW 1234H, 3456H;
Declares an array of 2 words and initialize them with
the specified values
Data declaration directives
● examples:
ARRAY DD 25629261H;
This will define a double word named ARRAY and
initialize the double word with the specified value when
the program is loaded into memory to be run. The low
word, 9261H, will be put in memory at a lower address
than the high word.
Data declaration directives (cont.)
● 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.
Data declaration directives (cont.)
Example:
PACKED_BCD DT 11223344556677889900
This will declare an array named PACKED_BCD, which is
10 bytes in length. It will initialize the 10 bytes with the
values 11, 22, 33, 44, 55, 66, 77, 88, 99, and 00 when the
program is loaded into memory to be run. The statement
RESULT DT 20H DUP (0) will declare an array of 20H
blocks of 10 bytes each and initialize all 320 bytes to 00
when the program is loaded into memory to be run.
ASSUME DIRECTIVE
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.
Eg:
● Example:
MODULE1 SEGMENT
PUBLIC FACTORIAL FAR
MODULE1 ENDS
MODULE2 SEGMENT
EXTRN FACTORIAL FAR
MODULE2 ENDS
TYPE (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
LABEL
● LABEL: 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 bespecified as type near or type far.
NAME, LABEL, SHORT, GLOBAL
● 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
● 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