You are on page 1of 17

Assembler Directives

Procedure Definition
Directives
Used to define subroutines
PROC
ENDP

PROC-Procedure
Used to identify the start of a procedure
PROC directive follows a name you give the procedure
After the PROC directive, the term NEAR or the term
FAR is used to specify the type of the procedure
Syntax
Procedurename PROC [NEAR/FAR]
READ PROC
Body of the procedure;
READ ENDP
SMART_DIVIDE PROC FAR

ENDP End Procedure


ENDP directive is used along with the
name of the procedure indicate the
end of a procedure to the assembler.
This directive together with the
procedure directive, PROC, is used to
bracket a procedure
General Syntax
Procedure ENDP

Macro
Macros are just like procedures, but not
really. Macros look like procedures, but
they exist only until your code is
compiled, after compilation all macros
are replaced with real instructions.
Macro definition:
name MACRO [parameters,...]
<instructions>
ENDM

Macro Definition Directives


The macro definition are used to
define macro constants and macro
functions
The directives EQU,MACRO and
ENDM are used in the definition of
macros

EQU (Equate)
Is used to a given name to some
value or symbol
Syntax
Symbolname EQU expression
Each time the assembler finds the
given name in the program, it will
replace the name with the value or
symbol you equated with that name

EQU
Example
CORRECTION_FACTOR EQU 03H written at
the start of the program
Later time suppose we wrote
ADD AL, CORRECTION_FACTOR
The assembler will code it as follows
ADD AL, 03H
The advantage is that the modification of
the program made easier

MACRO
It informs the assembler the
beginning of a MACRO
Syntax
Macro definition:
name MACRO [parameters,...]
<instructions>
ENDM

MACRO EXAMPLE
MyMacro MACRO p1, p2, p3
MOV AX, p1
MOV BX, p2
MOV CX, p3
ENDM
ORG 100h
MyMacro 1, 2, 3
RET
Result
MOV AX, 00001h
MOV BX, 00002h
MOV CX, 00003h

ENDM
Informs the assembler the end of a macro
Syntax
ENDM
Example
MyMacro MACRO p1, p2, p3
MOV AX, p1
MOV BX, p2
MOV CX, p3
ENDM

Data Control Directive


They are used to declare variables
that are used in communications
between program modules
They include
PUBLIC
EXTERN
PTR

Branch Displacement Directives


Used to control the branch
displacement
They are SHORT and LABEL

SHORT
It is used to inform the assembler that a one
byte jump is needed to code a jump
instruction
Normally, two byte memory is reserved for
the target address in the jump instruction
The SHORT with jump will reserve one byte
of memory
Example
JMP SHORT SKIP
SKIP: INC CX

LABEL
The LABEL directive is used to give a name to
the current value in the location counter.
The LABEL directive must be followed by a term
which specifies the type you want to associated
with that name
Syntax
Name LABEL type
It creates a new variable or label of a given size at
a specified location by assigning the current
location counter value and the given type to
name

Header File Inclusion


Directives
Is used to define include file header
The header file inclusion directive is
INCLUDE

INCLUDE
Include source code from file
The name of the include file follows
the directive INCLUDE
Used to place macros
Syntax
INCLUDE <file path specifications>
Example
INCLUDE MACRO.LIB

You might also like