22.02.2015 Views

HLASM Language Reference

HLASM Language Reference

HLASM Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How to Specify Macro Definitions<br />

Chapter 7. How to Specify Macro Definitions<br />

A macro definition is a set of statements that defines the name, the format, and the<br />

conditions for generating a sequence of assembler language statements. The<br />

macro definition can then be called by a macro instruction to process the<br />

statements. See page 241 for a description of the macro instruction. To define a<br />

macro you must:<br />

Give it a name<br />

Declare any parameters to be used<br />

Write the statements it contains<br />

Establish its boundaries with a macro definition header statement (MACRO)<br />

and a macro definition trailer statement (MEND)<br />

Except for conditional assembly instructions, this chapter describes all the<br />

statements that can be used to specify macro definitions. Conditional assembly<br />

instructions are described in Chapter 9, “How to Write Conditional Assembly<br />

Instructions” on page 318.<br />

Where to Define a Macro in a Source Module<br />

Macro definitions can appear anywhere in a source module. They remain in effect<br />

for the rest of your source module, or until another macro definition defining a<br />

macro with the same operation code is encountered, or until an OPSYN statement<br />

deletes its definition. Thus, you can redefine a macro at any point in your program.<br />

The new definition is used for all subsequent calls to the macro in the program.<br />

This type of macro definition is called a source macro definition, or, sometimes, an<br />

in-line macro definition. A macro definition can also reside in a system library; this<br />

type of macro is called a library macro definition. Either type can be called from<br />

the source module by the applicable macro instruction.<br />

Macro definitions can also appear inside other macro definitions. There is no limit<br />

to the levels of macro definitions permitted.<br />

The assembler does not process inner macro definitions until it finds the definition<br />

during the processing of a macro instruction calling the outer macro. The following<br />

example shows an inner macro definition:<br />

Example:<br />

MACRO<br />

Macro header for outer macro<br />

OUTER &A,&C= Macro prototype<br />

AIF<br />

('&C' EQ '').A<br />

MACRO<br />

Macro header for inner macro<br />

INNER<br />

Macro prototype<br />

.<br />

.<br />

MEND<br />

Macro trailer for inner macro<br />

.A ANOP<br />

.<br />

MEND<br />

Macro trailer for outer macro<br />

© Copyright IBM Corp. 1982, 2004 243

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!