beautypg.com

Concatenation – Zilog ZUSBOPTS User Manual

Page 276

background image

Macros

UM017105-0511

248

Zilog Developer Studio II – ZNEO™
User Manual

Syntax

<macroname>[:]

MACRO

[<arg>(,<arg>)...]

<macro_body>

ENDMAC

[RO]<macroname>

Example

store: MACRO reg1,reg2,reg3

ADD reg1,reg2

LD reg3,reg1

ENDMAC store

The following example contains a subtle error:

BadMac MACRO a,b,c

DL a,b,c

MACEND BadMac

Recall that b and c are reserved words on ZNEO, used for condition codes on the JP
instruction. Thus, they cannot be used as macro arguments. To avoid this and similar
errors, it is recommended that you avoid single character names.

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:

A 9 value val,part1

000000 55 A+ 9 DB val_part1

A+ 9 macend

A 10 value val,part2

000001 33 A+ 10 DB val_part2

Note:

This manual is related to the following products: