NOTE

NOTE

Assembler Directives and Pseudo-Operations

.MACRO Directive

Although there is no upper limit on the number of parameters or arguments in a macro definition, no single macro parameter may exceed 200 characters.

Macro definitions may appear wherever and as often as necessary within source code. Macro definitions may occur inside or outside of spaces, subspaces, and procedures.

Because the Assembler always uses the most recently encountered definition, macros may be redefined as often as desired.

A macro cannot be defined within the body of another macro definition.

Although nested macro definitions are not allowed, nested macro calls are. A nested macro call occurs when one macro is invoked within the definition of another macro. A macro may not be invoked within its own definition. Macros can only be invoked after being defined.

Examples

The macro definition defines a simple counter or timer called DECR.

DECR

.MACRO

LAB,VAL

SETP

ADDIL

L'VAL-$global$,%dp

LAB

LDW

R'VAL-$global$(%r1),%r20

ADDIBF,=

-1,%r20,LAB

 

 

NOP

 

 

.ENDM

 

The following is an invocation of DECR:

DECR LOOP,COUNT

LOOP and COUNT are the actual parameters that are specific to this particular invocation of the macro DECR.

During macro expansion, textual substitution for positional parameters is performed in the body of the macro definition. Substitution is performed on strings of characters that are delimited by blanks, tabs, commas, or semicolons. If the string matches one of the formal parameters, it is replaced with the corresponding actual parameter.

When a macro definition contains a label, the expanded form of the macro adds a unique suffix to the label for each instance the macro is invoked. This unique suffix prevents duplicate symbols from occurring

Chapter 4

99