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.

Introduction to Macro <strong>Language</strong><br />

generation, do not generate assembler language statements, but do only internal<br />

processing.<br />

A macro definition provides the assembler with:<br />

The name of the macro<br />

The parameters used in the macro<br />

The sequence of statements the assembler generates when the macro<br />

instruction appears in the source program.<br />

Every macro definition consists of a macro definition header statement (MACRO), a<br />

macro instruction prototype statement, one or more assembler language<br />

statements, and a macro definition trailer statement (MEND), as shown in<br />

Figure 62.<br />

┌──────────────────────────────► MACRO<br />

│<br />

┌────────────────────────────────────────────┐<br />

│ Prototype │ &LABEL MACID &PARAM1,&PARAM2 │<br />

│ │ └─┬─┘ └──────┬──────┘ │<br />

│ │ ▌2▐ ▌3▐ │<br />

│<br />

┌ ├────────────────────────────────────────────┤<br />

│ │ │ │<br />

▌1▐ ││ │<br />

│ │ │ │<br />

│ ▌5▐─┤ │ Body of macro │<br />

│ │ │ │<br />

│ │ │ │<br />

│ │ │ │<br />

│<br />

└ └────────────────────────────────────────────┘<br />

└──────────────────────────────► MEND<br />

▌4▐<br />

┌───────┴───────┐<br />

Macro instruction MACID OPERAND1,OPERAND2<br />

Figure 62. Parts of a Macro Definition<br />

The macro definition header and trailer statements (MACRO and MEND)<br />

indicate to the assembler the beginning and end of a macro definition (see ▌1▐<br />

in Figure 62).<br />

The macro instruction prototype statement names the macro (see ▌2▐ in<br />

Figure 62), and declares its parameters (see ▌3▐ in Figure 62). In the operand<br />

field of the macro instruction, you can assign values (see ▌4▐ in Figure 62) to<br />

the parameters declared for the called macro definition.<br />

The body of a macro definition (see ▌5▐ in Figure 62) contains the statements<br />

that are generated when you call the macro. These statements are called<br />

model statements; they are usually interspersed with conditional assembly<br />

statements or other processing statements.<br />

Model Statements<br />

You can write machine instruction statements and assembler instruction statements<br />

as model statements. During macro generation, the assembler copies them exactly<br />

as they are written. You can also use variable symbols as points of substitution in<br />

a model statement. The assembler enters values in place of these points of<br />

substitution each time the macro is called.<br />

Chapter 6. Introduction to Macro <strong>Language</strong> 239

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

Saved successfully!

Ooh no, something went wrong!