Professional Documents
Culture Documents
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
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
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
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
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