HLASM Language Reference
HLASM Language Reference HLASM Language Reference
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
- Page 282 and 283: System Variable Symbols System Vari
- Page 284 and 285: &SYSADATA_MEMBER System Variable Sy
- Page 286 and 287: &SYSCLOCK System Variable Symbol &S
- Page 288 and 289: &SYSECT System Variable Symbol depe
- Page 290 and 291: &SYSIN_MEMBER System Variable Symbo
- Page 292 and 293: &SYSJOB System Variable Symbol &SYS
- Page 294 and 295: &SYSLIN_DSN System Variable Symbol
- Page 296 and 297: &SYSLIST System Variable Symbol The
- Page 298 and 299: &SYSLOC System Variable Symbol To
- Page 300 and 301: &SYSM_SEV System Variable Symbol &S
- Page 302 and 303: &SYSNDX System Variable Symbol The
- Page 304 and 305: &SYSOPT_DBCS System Variable Symbol
- Page 306 and 307: &SYSPARM System Variable Symbol Not
- Page 308 and 309: &SYSPRINT_MEMBER System Variable Sy
- Page 310 and 311: &SYSPUNCH_MEMBER System Variable Sy
- Page 312 and 313: &SYSSTEP System Variable Symbol Not
- Page 314 and 315: &SYSTERM_DSN System Variable Symbol
- Page 316 and 317: &SYSTIME System Variable Symbol Not
- Page 318 and 319: Macro Instruction Format sequence_s
- Page 320 and 321: Macro Instruction Format Operand En
- Page 322 and 323: Macro Instruction Format When you n
- Page 324 and 325: Sublists in Operands the order in w
- Page 326 and 327: Sublists in Operands &SYSLIST( n,m)
- Page 328 and 329: Values in Operands Notes: 1. Spaces
- Page 330 and 331: Values in Operands Parentheses In m
- Page 334 and 335: Levels of Macro Call Nesting When t
- Page 336 and 337: Levels of Macro Call Nesting System
- Page 338 and 339: How to Write Conditional Assembly I
- Page 340 and 341: SET Symbols SET Symbol Specificatio
- Page 342 and 343: SET Symbols Figure 86 (Page 3 of 3)
- Page 344 and 345: Data Attributes this example indica
- Page 346 and 347: Data Attributes variable_symbol is
- Page 348 and 349: Data Attributes The value of an att
- Page 350 and 351: Data Attributes The following attri
- Page 352 and 353: Data Attributes Assembler gives a t
- Page 354 and 355: Data Attributes The scale attribute
- Page 356 and 357: Data Attributes Number Attribute (N
- Page 358 and 359: Data Attributes The operation code
- Page 360 and 361: Lookahead MACRO &NAME MOVE &TO,&FRO
- Page 362 and 363: Open Code Sequence Symbols The cond
- Page 364 and 365: GBLA, GBLB, and GBLC Instructions G
- Page 366 and 367: LCLA, LCLB, and LCLC Instructions s
- Page 368 and 369: SETA Instruction expression is an a
- Page 370 and 371: SETA Instruction | The logical-exp
- Page 372 and 373: SETA Instruction | Figure 99 (Page
- Page 374 and 375: SETA Instruction | The result of C2
- Page 376 and 377: SETA Instruction NOT Format: Logica
- Page 378 and 379: SETA Instruction | X2A Name Operati
- Page 380 and 381: SETA Instruction In evaluating the
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