beautypg.com

Macro invocation, Local macro labels, Optional macro arguments – Zilog ZUSBOPTS User Manual

Page 277

background image

UM017105-0511

Macros

Zilog Developer Studio II – ZNEO™

User Manual

249

A+ 10 macend

Macro Invocation

A macro is invoked by specifying the macro name and following the name with the
desired arguments. Use commas to separate the arguments.

Syntax

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

Example

store R1,R2,R3

This macro invocation causes registers R1 and R2 to be added and the result stored in reg-
ister R3.

Local Macro Labels

Local macro labels allow labels to be used within multiple macro expansions without
duplication. When used within the body of a macro, symbols preceded by two dollar signs
(

$$

) are considered local to the scope of the macro and therefore are guaranteed to be

unique. The two dollars signs are replaced by an underscore followed by a macro invoca-
tion number.

Syntax

$$

<label>

Example

LJMP: MACRO cc,label

JP cc,$$lab

JP label

$$lab:

ENDMAC

Optional Macro Arguments

A macro can be defined to handle omitted arguments using the

IFMA

(if macro argument)

conditional directive within the macro. The conditional directive can be used to detect if
an argument was supplied with the invocation.

Example

MISSING_ARG: MACRO ARG0,ARG1,ARG2

IFMA 2

This manual is related to the following products: