beautypg.com

Macros, Macro definition, Concatenation – Zilog EZ80F916 User Manual

Page 239: Macro definition concatenation

background image

UM014423-0607

ZiLOG Developer Studio II

eZ80Acclaim!

®

User Manual

219

MACROS

Macros allow a sequence of assembly source lines to be represented by a single assembler
symbol. In addition, arguments can be supplied to the macro in order to specify or alter the
assembler source lines generated once the macro is expanded. The following sections
describe how to define and invoke macros:

“MACRO Definition” on page 219

“Concatenation” on page 219

“Macro Invocation” on page 220

“Local Macro Labels” on page 220

“Optional Macro Arguments” on page 221

“Exiting a Macro” on page 221

“Delimiting Macro Arguments” on page 222

MACRO Definition

A macro definition must precede the use of the macro. The macro name must be the same
for both the definition and the

ENDMACRO

line. The argument list contains the formal argu-

ments that are substituted with actual arguments when the macro is expanded. The argu-
ments can be optionally prefixed with the substitution character (\) in the macro body.

During the invocation of the macro, a token substitution is performed, replacing the formal
arguments (including the substitution character, if present) with the actual arguments.

Syntax

<macroname>[:]MACRO[<arg>(,<arg>)...]

<macro_body>

ENDMAC[RO]<macroname>

Example

add3: MACRO reg1,reg2,reg3

LD reg1,reg2

ADD reg1,reg3

ENDMAC add3

Concatenation

To facilitate unambiguous symbol substitution during macro expansion, the concatenation
character (&) can be suffixed to symbol names. The concatenation character is a syntactic
device for delimiting symbol names that are points of substitution and is devoid of seman-
tic content. The concatenation character, therefore, is discarded by the assembler, when
the character has delimited a symbol name. For example:

This manual is related to the following products: