LCD Type MCU
Macro Directives
Macro directives enable a block of source statements to be named, and then that name to be
re-used in the source file to represent the statements. During assembly, the Cross Assembler auto-
matically replaces each occurrence of the macro name with the statements in the macro definition.
A macro can be defined at any place in the source file as long as the definition precedes the first
source line that calls this macro. In the macro definition, the macro to be defined may refer to other
macros which have been previously defined. The Cross Assembler supports a maximum of 7 nest-
ing levels.
Syntax
name
MACRO
[dummy-parameter [, ...]]
statements
ENDM
The Cross Assembler supports a directive
LOCAL
for the macro definition.
Syntax
name
LOCAL
dummy-name
[, ...]
·
Description
The
LOCAL
directive defines symbols available only in the defined macro. It must be the first line
following the
MACRO
directive, if it is present. The
dummy-name
is a temporary name that is re-
placed by a unique name when the macro is expanded. The Cross Assembler creates a new ac-
tual name for
dummy-name
each time the macro is expanded. The actual name has the form
??digit,
where digit is a hexadecimal number within the range from 0000 to FFFF. A label
should be added to the
LOCAL
directive when labels are used within the
MACRO/ENDM
block.
Otherwise, the Cross Assembler will issue an error if this
MACRO
is referred to more than once in
the source file.
In the following example,
tmp1
and
tmp2
are both dummy parameters, and are replaced by ac-
tual parameters when calling this macro.
label1
and
label2
are both declared
LOCAL,
and
are replaced by
??0000
and
??0001
respectively at the first reference, if no other
MACRO
is re-
ferred. If no
LOCAL
declaration takes place,
label1
and
label2
will be referred to labels, simi-
lar to the declaration in the source program. At the second reference of this macro, a multiple
define error message is displayed.
Delay MACRO
tmp1, tmp2
LOCAL
label1, label2
mov
a, 70h
mov
tmp1, a
label1:
mov
tmp2, a
label2:
clr
wdt1
clr
wdt2
sdz
tmp2
jmp
label2
sdz
tmp1
jmp
label1
ENDM
146
Home Index Bookmark Pages Text
Previous Next
Pages: Home Index