HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Macro definition

HLASM Language Reference
SC26-4940-06

A macro definition is a named sequence of statements you can call with a macro instruction. When it is called, the assembler processes and normally generates assembler language statements from the definition into the source module. The statements generated can be:
  • Copied directly from the definition
  • Modified by parameter values and other values in variable symbols before generation
  • Manipulated by internal macro processing to change the sequence in which they are generated

You can define your own macro definitions in which any combination of these three processes can occur. Some macro definitions, like some of those used for system generation, do not generate assembler language statements, but do only internal processing.

A macro definition provides the assembler with:
  • The name of the macro
  • The parameters used in the macro
  • The sequence of statements the assembler generates when the macro instruction appears in the source program.
Every macro definition consists of a macro definition header statement (MACRO), a macro instruction prototype statement, one or more assembler language statements, and a macro definition trailer statement (MEND), as shown in Figure 1.
Figure 1. Parts of a macro definition
 ┌──────────────────────────────> MACRO
 │                     ┌────────────────────────────────────────────┐
 │  Prototype          │ &LABEL   MACID    &PARAM1,&PARAM2          │
 │                     │          └─┬─┘    └──────┬──────┘          │
 │                     │            2             3                 │
 │                   ┌ ├────────────────────────────────────────────┤
 │                   │ │                                            │
 1                   │ │                                            │
 │                   │ │                                            │
 │                5 ─┤ │          Body of macro                     │
 │                   │ │                                            │
 │                   │ │                                            │
 │                   │ │                                            │
 │                   └ └────────────────────────────────────────────┘
 └──────────────────────────────> MEND

                                                   4 
                                           ┌───────┴───────┐
    Macro instruction             MACID    OPERAND1,OPERAND2
  • The macro definition header and trailer statements (MACRO and MEND) indicate to the assembler the beginning and end of a macro definition (see  1  in Figure 1).
  • The macro instruction prototype statement names the macro (see  2  in Figure 1), and declares its parameters (see  3  in Figure 1). In the operand field of the macro instruction, you can assign values (see 4  in Figure 1) to the parameters declared for the called macro definition.
  • The body of a macro definition (see  5  in Figure 1) contains the statements that are generated when you call the macro. These statements are called model statements; they are normally interspersed with conditional assembly statements or other processing statements.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014