beautypg.com

Optional macro arguments, Exiting a macro, Optional macro arguments exiting a macro – Zilog EZ80F916 User Manual

Page 241

background image

UM014423-0607

ZiLOG Developer Studio II

eZ80Acclaim!

®

User Manual

221

Example

LJMP: MACRO cc,label

JR 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 ARG1,ARG2,ARG3

IFMA 2

LD ARG1,ARG2

ELSE

LD ARG1,ARG3

ENDIF

ENDMACRO MISSING_ARG

Invocation

MISSING_ARG A, ,(HL) ; second argument is not defined

Result

LD A,(HL)

Exiting a Macro

The

MACEXIT

directive is used to immediately exit a macro. No further processing is per-

formed. However, the assembler checks for proper if-then conditional directives. A

MACEXIT

directive is normally used to terminate a recursive macro.

The following example is a recursive macro that demonstrates using

MAXEXIT

to termi-

nate the macro.

Example

RECURS_MAC: MACRO ARG1,ARG2

IFMA 0

MACEXIT

ELSE

RECURS_MAC ARG2

DB ARG1

ENDIF

This manual is related to the following products: