EasyManua.ls Logo

Intel 8080 - B4_Page_15

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
Example
1:
Nested I
RPC
The following macro definition contains a nested
IRPC
directive. Notice that the third operand
of
the outer
macro becomes the character string for the
I
RPC:
MOVE
MACRO
IRPC
LHLD
SHLD
ENDM
ENDM
X,Y,Z
PARAM,Z
X&&PARAM
Y&&PARAM
Assume that the program contains the
call
MOVE
SRC,DST,123. The third parameter
of
this
call
is
passed to
the
I
RPC.
This has the same effect
as
coding I
RPC
PARAM,123.
When
expanded, the
MOVE
macro generates
the following source code:
LHLD
SRC1
SHLD
DST1
LHLD
SRC2
SHLD DST2
LHLD
SRC3
SHLD
DSn
Notice the
use
of
concatenation to form labels
in
this example.
Example
2:
Nested Macros U,ed to Generate
DB
Directives
This example generates a number of
DB
0 directives, each with its own label.
Two
macros are
used
for this
purpose:
INC
and BLOCK. The
INC
macro
is
defined
as
follows:
INC
$
SAVE
GEN
F1
&F2:
$ RESTORE
MACRO
DB
ENDM
F1,F2
o ;GENERATE LABELS & DB's
The
BLOCK
macro, which accepts the number of DB's to
be
generated
(NUMB)
and a
label
prefix (PREFIX),
is
defined
as
follows:
$
BLOCK
MACRO
SAVE NOGEN
COUNT
COUNT
SET
REPT
SET
INC
ENDM
$ RESTORE
ENDM
NUMB,PREFIX
o
NUMB
COUNT+1
PREFIX,%COUNT ;NESTED
MACRO
CALL
S-17

Table of Contents

Related product manuals