EasyManua.ls Logo

Intel 8080 - B4_Page_04

Intel 8080
224 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter
5. Macros
5-6
Dummy parameters included
in
a macro call cannot
be
operands
of
a LOCAL directive. The scope
of
a dummy
parameter
is
always local to its own macro definition.
Local symbols can be defined only within a macro definition. Any number
of
LOCAL directives may appear
in
a macro definition,
but
they must
all
follow the macro call and must precede the first line
of
prototype code.
A
LOCAL directive appearing outside a macro definition causes an error. Also, a name appearing
in
the label
field
of
a LOCAL directive causes an error.
Example:
The definition of
MAC1
(used as an example
in
the description
of
the MACRO directive) contains a potential
error because the symbol MOVES has not been declared local. This
is
a potential error since no error occurs
if
MAC1
is
called only once
in
the program, and the program itself does
not
use MOVES as a symbol. However,
if
MAC1
is
called more than once, or if the program uses the symbol MOVES, MOVES
is
a multiply·defined
symbol.
This potential error
is
avoided by naming MOVES
in
the operand field
of
a LOCAL directive:
MAC1
MACRO
Gl,G2,G3
LOCAL MOVES
MOVES:
LHLD
Gl
MOV
A,M
LHLD G2
MOV
B,M
LHLD G3
MOV
C,M
ENDM
Assume
that
MAC1
is
the only macro
in
the program and that it
is
called twice. The first time MACl
is
expanded,
MOVES
is
replaced with the symbol
??OOOl;
the second time, MOVES
is
replaced with ??0002. Because the
assembler encounters only these special replacement symbols, the program may contain the symbol MOVES
without causing a multiple definition.
REPT
Directive
Label Opcode
Operand
optional:
REPT
expression
The
REPT directive causes a sequence
of
source code lines to be repeated 'expression' times.
All
lines appearing
between the
REPT directive and a subsequent
ENDM
directive constitute the block to be repeated.
When
'expression' contains symbolic names, the assembler must encounter the definition
of
the symbol prior
to
encou nteri
ng
the expression.
The insertion
of
repeat blocks
is
performed in·line when the assembler encounters the REPT directive. No
explicit call
is
required to cause the code insertion since the definition
is
an
implied call for expansion.

Table of Contents

Related product manuals