Lecture-36 Assembler Directives
Lecture-36 Assembler Directives
Lecture-36 Assembler Directives
ASSEMBLER DIRECTIVES
To assemble a program automatically the assembler needs
information in the form of assembler directives that controls the
assembly. For example, the assembler must be told at what address
to start assembling the program. These assembler directives are
command placed in the program by the designer that provides
information to the assembler. They do not become part of the final
program as they are not the part of the instruction set of the
microprocessor nor did they translate into executable code.
Therefore, they are also known as pseudo-instruction on false
instructions.
Each assembler has its own unique pseudo instructions or
assembler directives. These instructions differ from assembler to
assembler but most of the assembler contains an equivalent set of
pseudo instructions written in assembly language format.
Example-1:
Consider the use of a macro involving a large amount of indirect
addressing. An indirect addressing input capability is provided by the
two instructions:
LHLD addr
MOV r, M
This sequence can be written as a macro named LDIND; with a
macro definition of
LDIND MACRO REG, ADDR
LHLD ADDR
MOV REG, M
ENDM
To have the macro body appear at any given point in the program, it
requires a macro reference. This format is identical to that of an
assembly language instruction.
Label Code (Mnemonic) Operand
optional label name parameters list
‘Name’ is the label by which the macro is referenced or called. The
following macro instructions load register (C) indirectly through the
address PRT
LDIND C, PTR
When a program containing macro is input to a macro assembler the
assembler carries out a test substitution, the macro expansion,
substituting for each macro reference the macro body specified in the
macro definition. And for each dummy parameter list in the macro
body, the appropriate parameter from the parameter list of the macro
reference macro assembler encounter the macro instruction
LDIND C, PTR
It replaces it with the instructions
LHLD PTR
MOV C, M
Example-2:
The following macro rotation the contents of the accumulator to the
left through carry, N times. This is done with a loop that is terminated
when a register is counted down to zero. The numbers of rotation, N.
and the register to be used as the counter are the parameters in the
macro definition:
RALN MACRO N, REG
MVI REG, N
LOOP: RAL
DCR REG
JNZ LOOP
ENDM
If this macro appears in a program, a problem results as it will be
referred twice. When the macro is expanded, the label LOOP will
appear twice in the program, resulting in a multiply define symbol
error when the program is assembled. This problem is avoided by
use of the LOCAL directive; which is placed in the macro definition.
The LOCAL directive has the form:
LABEL CODE OPERAND