EasyManua.ls Logo

Intel 8080 - B4_Page_16

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-18
The macro call
BLOCK
3,LAB generates the following source code:
LAB1:
LAB2:
LAB3:
BLOCK
DB
DB
DB
3,LAB
o
o
o
The assembler controls specified
in
these two macros (the lines beginning with
$)
are
used
to clean
up
the
assembly listing for easier reading. The source code shown for the
call
BLOCK
3,LAB
is
what appears
in
the
assembly listing when the controls are used. Without the controls, the assembly listing appears
as
follows:
BLOCK
3,LAB
COUNT
SET
0
REPT
3
COUNT
SET
COUNT+1
INC
LAB,%COUNT
ENDM
COUNT
SET
COUNT+1
INC
LAB,%COUNT
LAB1
:
DB
0
COUNT
SET
COUNT+l
INC
LAB,%COUNT
LA,B2:
DB
0
COUNT
SET
COUNT+l
INC
LAB,%COUNT
LAB3:
DB
0
Example
3:
A
Macro
that Converts Itself into a Subroutine
In
some cases, the in-line coding substituted for each macro
call
imposes
an
unacceptable memory requirement.
The next three examples show three different methods for converting a macro
call
into a subroutine call. The
first time the
SBMAC
macro
is
called,
it
generates a
full
in-line substitution which defines the
SUBR
subroutine.
Each
subsequent
call
to the
SBMAC
macro generates only a
CALL
instruction
to
the
SUBR
subroutine.
Within the following examples, notice that the label
SUBR
must
be
global
so
that
it
can
be
called from outside
the first expansion. This
is
possible only when that part of the macro definition contai
ning
the global label
is
called only once
in
the entire program.
Method #1: Nested
Macro
Definitions
Macros
can
be
redefined during the course of a program.
In
the following example, the definition of
SBMAC
contains its own redefinition
as
a nested macro. The first time
SBMAC
is
called,
it
is
full
expanded, and the
redefinition of
SBMAC
replaces the original definition. The second time
SBMAC
is
called, only its redefinition
(a
CALL
instruction)
is
expanded.

Table of Contents

Related product manuals