Definition: Assembler directives are the instructions used by the assembler at the time of assembling a source program. More specifically, we can say, assembler directives are the commands or instructions that control the operation of the assembler.
Assembler directives are the instructions provided to the assembler, not the processor as the processor has nothing to do with these instructions. These instructions are also known as pseudo-instructions or pseudo-opcode.
Now the question arises what assembler directives specifically do?
So, assembler directives:
- show the beginning and end of a program provided to the assembler,
- used to provide storage locations to data,
- used to give values to variables,
- define the start and end of different segments, procedures or macros etc. of a program.
Content: Assembler Directives
What is an Assembler?
We know that assembly language is a less complex and programmer-friendly language used to program the processors.
In assembly language programming, the instructions are specified in the form of mnemonics rather in the form of machine code i.e., 0 and 1.
But the microprocessor or microcontrollers are specifically designed in a way that they can only understand machine language.
Thus assembler is used to convert assembly language into machine code so that it can be understood and executed by the processor.
Therefore, to control the generation of machine codes from the assembly language, assembler directives are used.
Assembler Directives of 8085
The assembler directives given below are used by 8085 and 8086 assemblers:
DB: Define Byte
This directive is used for the purpose of allocating and initializing single or multiple data bytes.
Memory name AREA has three consecutive locations where 30H, 52H and 35H are to be stored.
DW: Define Word
It is used for initialising single or multiple data words (16-bit).
These two 16-bit data 1020H and 4216H are stored at 4 consecutive locations in the memory MARK.
END: End of program
This directive is used at the time of program termination.
It is used to assign any numerical value or constant to the variable.
Variable name ‘DONE’ has value 10H
MACRO: Represents beginning
Shows the beginning of macro along with defining name and parameters.
ENDM: End of macro
ENDM indicates the termination of macro.
where macroname (STEP) is specified by the user.
This directive is used at the time of assigning starting address for a module or segment.
Assembler Directives of 8086
These assembler directives are specifically used by 8086:
ASSUME: Shows the segment name to the assembler
It provides information to the assembler regarding the name of the program or data segment for that particular segment.
This directive specifies that the instruction of the source program is stored in logical segment _DONE.
DD: Define Double word
This directive allows the initialization of single or multiple data in the form of double words (i.e., 4 bytes). The is used to inform the assembler that the stored data in memory is a double word.
Thus memory stores the given data in the form:
DQ: Define Quad words
It is used to initialise quad words (8-bytes) either one or more than one. Thereby informing the assembler that the data stored in memory is quad-word.
DT: Define ten bytes
It is used to allocate and initialize 10 bytes of a variable.
DUP allows initialization of multiple locations and assigning of values to them. This allows storing of repeated characters or variables in different locations.
So this permits the storing of these data in memory and creating 8 identical sets in the memory identified as Book.
DWORD: Double word
This directive is used to indicate that the operand is of double word size.
It defines the starting of a procedure/subroutine.
FAR: This directive is a type specifier that is used by the assembler to declare intersegment call (i.e., call from different segment).
NEAR: This is used for intrasegment call i.e., a call within the same segment.
ENDP: End of procedure
This directive shows the termination of a procedure.
SEGMENT: Beginning of a memory segment.
It is used to show the beginning of a memory segment with a specific name.
ENDS: End of segment
This directive defines the termination of a particular memory segment as it is specified by its name.
The statements within the segment are nothing but the program code.
EVEN: It is used to inform the assembler to align the data beginning from an even address.
As data specified with an odd starting address requires 2 byte accessing. Thus using this directive, data can be aligned with an even starting address.
This directive shows information regarding the size of the operand.
This shows legal near jump to BX.
PUBLIC: This directive is used to provide a declaration to variables that are common for different program modules.
STACK: This directive shows the presence of a stack segment.
SHORT: This is used in reference to jump instruction in order to assign a displacement of one byte.
THIS: It is used along with EQU directive for setting the label to either, byte, word or double-word.
So, these assembler directives are used by the processors for controlling the generation of machine code and organization of the program.