11.07.2015 Views

HLASM: V1R6 Language Ref

HLASM: V1R6 Language Ref

HLASM: V1R6 Language Ref

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7. How to specify macro definitionsA macro definition is a set of statements that defines the name, the format, and theconditions for generating a sequence of assembler language statements. The macrodefinition can then be called by a macro instruction to process the statements. Seepage 237 for a description of the macro instruction. To define a macro you must:v Give it a namev Declare any parameters to be usedv Write the statements it containsv Establish its boundaries with a macro definition header statement (MACRO) anda macro definition trailer statement (MEND)Except for conditional assembly instructions, this chapter describes all thestatements that can be used to specify macro definitions. Conditional assemblyinstructions are described in Chapter 9, “How to write conditional assemblyinstructions,” on page 315.Where to define a macro in a source moduleMacro definitions can appear anywhere in a source module. They remain in effectfor the rest of your source module, or until another macro definition defining amacro with the same operation code is encountered, or until an OPSYN statementdeletes its definition. Thus, you can redefine a macro at any point in yourprogram. The new definition is used for all subsequent calls to the macro in theprogram.This type of macro definition is called a source macro definition, or, sometimes, anin-line macro definition. A macro definition can also reside in a system library; thistype of macro is called a library macro definition. Either type can be called from thesource module by the applicable macro instruction.Macro definitions can also appear inside other macro definitions. There is no limitto the levels of macro definitions permitted.The assembler does not process inner macro definitions until it finds the definitionduring the processing of a macro instruction calling the outer macro. The followingexample shows an inner macro definition:Example:MACRO Macro header for outer macroOUTER &A,&C= Macro prototypeAIF (’&C’ EQ ’’).AMACRO Macro header for inner macroINNER Macro prototype..MEND Macro trailer for inner macro.A ANOP.MEND Macro trailer for outer macroThe assembler does not process the macro definition for INNER until OUTER is calledwith a value for &C other than a null string.© Copyright IBM Corp. 1982, 2008 241

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

Saved successfully!

Ooh no, something went wrong!