HLASM Language Reference

HLASM Language Reference HLASM Language Reference

faculty.cs.niu.edu
from faculty.cs.niu.edu More from this publisher
22.02.2015 Views

Inner and Outer Macro Instructions 1 macro 2 &name ainsert_test_macro 3 ainsert ' Macro',back 4 ainsert ' mac1',back 5 ainsert 'Blah blah blah',front 6 &aread aread 7 &aread setc '&aread'(1,1) 8 ainsert '&&n seta n''&&syslist ',back 9 ainsert ' dc a(&&n)',back 1 ainsert ' dc c''&aread'' ',back 11 ainsert ' mend',back 12 mend 13 14 testains csect 15 16 ainsert_test_macro 17+ ainsert ' Macro',back 18+ ainsert ' mac1',back 19+ ainsert 'Blah blah blah',front 2-Blah blah blah 21+ ainsert '&&n seta n''&&syslist ',back 22+ ainsert ' dc a(&&n)',back 23+ ainsert ' dc c''Blah blah '' ',back 24+ ainsert ' mend',back 25> Macro 26> mac1 27>&n seta n'&syslist 28> dc a(&n) 29> dc c'Blah blah ' 3> mend 31 32 mac1 a,b,c,d,e,f,g 33+ dc a(7) 34+ dc c'Blah blah ' 35 36 end Figure 83. Expanding Nested Macro Definitions Inner and Outer Macro Instructions Any macro instruction you write in the open code of a source module is an outer macro instruction or call. Any macro instruction that appears within a macro definition is an inner macro instruction or call. Levels of Macro Call Nesting The code generated by a macro definition called by an inner macro call is nested inside the code generated by the macro definition that contains the inner macro call. In the macro definition called by an inner macro call, you can include a macro call to another macro definition. Thus, you can nest macro calls at different levels. The &SYSNEST system variable indicates how many levels you called. It has the value 1 in an outer macro, and is incremented by one at a macro call. 312 HLASM V1R5 Language Reference

Levels of Macro Call Nesting Recursion You can also call a macro definition recursively; that is, you can write macro instructions inside macro definitions that are calls to the containing definition. This is how you define macros to process recursive functions. General Rules and Restrictions Macro instruction statements can be written inside macro definitions. Values are substituted in the same way as they are for the model statements of the containing macro definition. The assembler processes the called macro definition, passing to it the operand values (after substitution) from the inner macro instruction. In addition to the operand values described in “Values in Operands” on page 307, nested macro calls can specify values that include: Any of the symbolic parameters (see ▌1▐ in Figure 84) specified in the prototype statement of the containing macro definition Any SET symbols (see ▌2▐ in Figure 84) declared in the containing macro definition Any of the system variable symbols such as &SYSDATE, &SYSTIME, etc. (see ▌3▐ in Figure 84). ┌──────────── Parameters │ MACRO ┌────────┴────────┐ OUTERMAC &P1,&P2,&KEY1=VALUE Prototype . │ . ▌1▐ . │ LCLC &C──────────────►▌2▐ . │ │ . │ │ &C SETC 'ABC' │ │ . │ │ . ▼ ▼ INNERMAC &P1,&KEY1,&C Inner macro call . └─────┬────┘ . └─────────────── Operands . MEND ───────────────────────────────────────────────────────────────────── MACRO OUT Prototype . . . ▌3▐ ▌3▐ ▌3▐ IN &SYSLIST(3),&SYSECT,A&SYSDNX Inner macro call . . MEND Figure 84. Values in Nested Macro Calls The number of nesting levels permitted depends on the complexity and size of the macros at the different levels; that is, the number of operands specified, the number of local-scope and global-scope SET symbols declared, and the number of sequence symbols used. Chapter 8. How to Write Macro Instructions 313

Levels of Macro Call Nesting<br />

Recursion<br />

You can also call a macro definition recursively; that is, you can write macro<br />

instructions inside macro definitions that are calls to the containing definition. This<br />

is how you define macros to process recursive functions.<br />

General Rules and Restrictions<br />

Macro instruction statements can be written inside macro definitions. Values are<br />

substituted in the same way as they are for the model statements of the containing<br />

macro definition. The assembler processes the called macro definition, passing to<br />

it the operand values (after substitution) from the inner macro instruction. In<br />

addition to the operand values described in “Values in Operands” on page 307,<br />

nested macro calls can specify values that include:<br />

Any of the symbolic parameters (see ▌1▐ in Figure 84) specified in the<br />

prototype statement of the containing macro definition<br />

Any SET symbols (see ▌2▐ in Figure 84) declared in the containing macro<br />

definition<br />

Any of the system variable symbols such as &SYSDATE, &SYSTIME, etc.<br />

(see ▌3▐ in Figure 84).<br />

┌──────────── Parameters<br />

│<br />

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

OUTERMAC &P1,&P2,&KEY1=VALUE Prototype<br />

. │<br />

. ▌1▐<br />

. │<br />

LCLC &C──────────────►▌2▐<br />

. │ │<br />

. │ │<br />

&C SETC 'ABC' │ │<br />

. │ │<br />

. ▼ ▼<br />

INNERMAC &P1,&KEY1,&C Inner macro call<br />

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

. └─────────────── Operands<br />

.<br />

MEND<br />

─────────────────────────────────────────────────────────────────────<br />

MACRO<br />

OUT<br />

Prototype<br />

.<br />

.<br />

. ▌3▐ ▌3▐ ▌3▐<br />

IN &SYSLIST(3),&SYSECT,A&SYSDNX Inner macro call<br />

.<br />

.<br />

MEND<br />

Figure 84. Values in Nested Macro Calls<br />

The number of nesting levels permitted depends on the complexity and size of the<br />

macros at the different levels; that is, the number of operands specified, the<br />

number of local-scope and global-scope SET symbols declared, and the number of<br />

sequence symbols used.<br />

Chapter 8. How to Write Macro Instructions 313

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

Saved successfully!

Ooh no, something went wrong!