beautypg.com

Macro definition, Concatenation, Macro definition concatenation – Zilog Z8F0130 User Manual

Page 353

background image

UM013037-1212

Macro Definition

Zilog Developer Studio II – Z8 Encore!

User Manual

329

Delimiting Macro Arguments

– see page 332

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

store: MACRO reg1,reg2,reg3

ADD reg1,reg2

LD reg3,reg1

ENDMAC store

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:

val_part1 equ 55h

val_part2 equ 33h

The assembly is:

value macro par1, par2

DB par1&_&par2

macend


value val,part1

value val,part2

The generated list file is: