SlideShare a Scribd company logo
1 of 20
System
Software
Chapter – 3
1. Macro expansion
2.nested macro calls
MACRO EXPANSION:
The use of a macro name with a set of actual parameters is
replaced by some code generated from its body.
This is called macro expansion .
Macro expansion can be performed by two kinds of language processor
 Macro assembler
 Macro pre-processor
MACRO ASSEMBLER:
Its performs expansion of a each macro call in a program into a sequence of assembly
language statements and also assembles the resultant assembly language program.
MACRO PRE-PROCESSOR:
It only processes the macro call. Other statements are processes with the help of assembler.
EXAMPLE FOR EXAPANSION
MACRO DEFINITION
EXPANSIONOF MACRO
Label field
 A ,B , AREG are an actual parameters.
 &MEM_VAL, &INC_VAL,&REG are formal
parameters.
Two key notions concerning macro expansion are
A. Expansion time control flow :
This determines the order in which model statements are visited during macro
expansion.
B. Lexical substitution:
Lexical substitution is used to generate an assembly statement from a model statement.
A. Flow of control during expansion
 The default flow of control during macro expansion is sequential.
 In the absence of preprocessor statements, the model statements
of a macro are visited sequentially starting with the statement
following the macro prototype statement and ending with the
statement preceding the MEND statement.
What can alter the flow of control during expansion?
o A pre-processor statement can alter the flow of control during expansion
such that
o Conditional Expansion: Some model statements are either never visited
during expansion, or Expansion Time Loops: are repeatedly visited
during expansion.
o The flow of control during macro expansion is implemented using a macro
expansion counter (MEC)
ALGORITHM (MACRO EXPANSION)
1. MEC:=statement number of first statement
following the prototype statement.
2. While statement pointed by MEC is not a MEND statement.
a. If a model statement then
i. Expand the statement
ii. MEC:=MEC+1;
b. Else (i.e. a preprocessor statement)
i. MEC:= new value specified in the statement.
3. Exit from macro expansion.
B. LEXICAL SUBSTITUTION
 A model statement consists of 3 types of strings.
 An ordinary string, which stands for itself.
 The name of a formal parameter which is preceded by the character
„&‟.
 The name of a pre-processor variable, which is also preceded by the
character „&‟.
 During lexical expansion, strings is retained in its original form .
 The name of Formal parameter is replaced by its value from the
actual parameter of a macro call.
 The name of pre-processor variable is replaced with its value. This
value is readily known to the pre-processor.
Rules for determining the value of a formal parameter depends on
the kind of parameter:
 Positional Parameter
 Keyword Parameter
 Default specification of parameters
 Macros with mixed parameter list
 Other uses of parameter
POSITIONAL PARAMETERS
A positional formal parameter is written as &<parameter name>
e.g. &SAMPLE where SAMPLE is the name of parameter.
<parameter kind> of syntax rule is omitted.
The value of a positional formal parameter XYZ is determined by the rule of
positional association as follows:
1. Find the ordinal position of XYZ in the list of formal parameters in the
macro prototype statement.
2. Find the actual parameter specification occupying the same ordinal position
in the list of actual parameters in the macro call statement.
Consider the call
INCR A,B,AREG
On macro INCR , following rule of positional association,
values of formal parameters are:
Formal parameter value
MEM_VAL A
INCR_VAL B
REG AREG
Lexical expansion of the model statements now leads to
the code
+ MOVER AREG, A
+ ADD AREG, B
+ MOVEM AREG, A
MACRO
INCR &MEM_VAL,&INCR_VAL
&REG
MOVER &REG, &MEM_VAL
ADD &REG, &INCR_VAL
MOVEM &REG, &MEM_VAL
MEND
Consider the macro
KEYWORD PARAMETER
For keyword parameter,
<parameter name> is an ordinary string and
<parameter kind> is the string „=‟ in syntax rule.
The <actual parameter spec> is written as<formal parameter name>=<ordinary
string>.
Note that the ordinal position of the specification XYZ=ABC in the list of actual
parameters is immaterial.
This is very useful in situations where long lists of parameters have to be used.
Let us see example for it.
Following are macro call statement:
INCR_M MEM_VAL=A, INCR_VAL=B, REG=AREG
------
INCR_M INCR_VAL=B, REG=AREG, MEM_VAL=A
Both are equivalent.
Following is macro definition using keyword parameter:
MACRO
INCR_M &MEM_VAL=, &INCR_VAL=,&REG=
MOVER &REG, &MEM_VAL
ADD &REG, &INCR_VAL
MOVEM &REG,&MEM_
DEFAULT SPECIFICATIONS OF PARAMETERS
A default value is a standard assumption in the absence of an explicit
specification by the programmer.
Default specification of parameters is useful in situations where a parameter
has the same value in most calls.
When the desired value is different from the default value, the desired value
can be specified explicitly in a macro call.
The syntax for formal parameter specification, as follows:
&<parameter name> [<parameter kind> [<default value>]]
EXAMPLE
MACRO
INCR_D &MEM_VAL=, &INCR_VAL=, &REG=AREG
MOVER &REG, &MEM_VAL
ADD &REG, &INCR_VAL
MOVEM &REG, &MEM_VAL
MEND
The macro can be redefined to use a default specification
for the parameter REG
INCR_D MEM_VAL=A, INCR_VAL=B
INCR_D INCR_VAL=B, MEM_VAL=A
INCR_D INCR_VAL=B, MEM_VAL=A, REG=BREG
First two calls are equivalent but third call overrides the default value for REG with the value BREG in next example.
MACROS WITH MIXED PARAMETER LISTS
A macro may be defined to use both positional and keyword parameters.
In such a case, all positional parameters must precede all keyword parameters.
example in the macro call
SUM A, B, G=20, H=X
A, B are positional parameters while G, H are keyword parameters.
Correspondence between actual and formal parameters is established by
applying the rules governing positional and keyword parameters separately.
OTHER USES OF PARAMETERS
The model statements have used formal parameters only in operand field.
However, use of parameters is not restricted to these fields.
Formal parameters can also appear in the label and opcode fields of model
statements.
NESTED MACRO CALLS
 A model statement in a macro may constitute a
call on another macro.
 Such calls are known as nested macro calls.
 Macro containing the nested call is the outer macro and, Macro called is
inner macro.
 They follow LIFO rule.
 Thus, in structure of nested macro calls, expansion of latest macro call (i.e
inner macro) is completed first.
THANK YOU

More Related Content

What's hot

System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit ISaranya1702
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1Manoj Patil
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loadersTech_MX
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language ProcessingHemant Sharma
 
Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Bhatt Balkrishna
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03desta_gebre
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programmingMukesh Tekwani
 
srs for railway reservation system
 srs for railway reservation system srs for railway reservation system
srs for railway reservation systemkhushi kalaria
 
Toy compiler
Toy compilerToy compiler
Toy compilerhome
 

What's hot (20)

Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Unit 2
Unit 2Unit 2
Unit 2
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Ch 3 Assembler in System programming
Ch 3 Assembler in System programming
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 
Unit 3
Unit 3Unit 3
Unit 3
 
Linking in MS-Dos System
Linking in MS-Dos SystemLinking in MS-Dos System
Linking in MS-Dos System
 
Assembler
AssemblerAssembler
Assembler
 
srs for railway reservation system
 srs for railway reservation system srs for railway reservation system
srs for railway reservation system
 
Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchart
 
Toy compiler
Toy compilerToy compiler
Toy compiler
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 

Similar to System software - macro expansion,nested macro calls

Similar to System software - macro expansion,nested macro calls (20)

Handout#05
Handout#05Handout#05
Handout#05
 
Module 5.pdf
Module 5.pdfModule 5.pdf
Module 5.pdf
 
Handout#04
Handout#04Handout#04
Handout#04
 
handout6.pdf
handout6.pdfhandout6.pdf
handout6.pdf
 
Task Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfTask Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdf
 
Ss4
Ss4Ss4
Ss4
 
Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01
 
C language 3
C language 3C language 3
C language 3
 
Writing command macro in stratus cobol
Writing command macro in stratus cobolWriting command macro in stratus cobol
Writing command macro in stratus cobol
 
Preprocessors
PreprocessorsPreprocessors
Preprocessors
 
N_Asm Assembly macros (sol)
N_Asm Assembly macros (sol)N_Asm Assembly macros (sol)
N_Asm Assembly macros (sol)
 
Macros in system programing
Macros in system programingMacros in system programing
Macros in system programing
 
LISP: Macros in lisp
LISP: Macros in lispLISP: Macros in lisp
LISP: Macros in lisp
 
LISP: Macros in lisp
LISP: Macros in lispLISP: Macros in lisp
LISP: Macros in lisp
 
Presentation on macros and macro processor
Presentation on macros and macro processorPresentation on macros and macro processor
Presentation on macros and macro processor
 
33443223 system-software-unit-iv
33443223 system-software-unit-iv33443223 system-software-unit-iv
33443223 system-software-unit-iv
 
SAS Macro
SAS MacroSAS Macro
SAS Macro
 
Inline functions & macros
Inline functions & macrosInline functions & macros
Inline functions & macros
 
Unit 5 Part 1 Macros
Unit 5 Part 1 MacrosUnit 5 Part 1 Macros
Unit 5 Part 1 Macros
 
Cpp functions
Cpp functionsCpp functions
Cpp functions
 

Recently uploaded

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 

Recently uploaded (20)

ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 

System software - macro expansion,nested macro calls

  • 1. System Software Chapter – 3 1. Macro expansion 2.nested macro calls
  • 2. MACRO EXPANSION: The use of a macro name with a set of actual parameters is replaced by some code generated from its body. This is called macro expansion .
  • 3. Macro expansion can be performed by two kinds of language processor  Macro assembler  Macro pre-processor MACRO ASSEMBLER: Its performs expansion of a each macro call in a program into a sequence of assembly language statements and also assembles the resultant assembly language program. MACRO PRE-PROCESSOR: It only processes the macro call. Other statements are processes with the help of assembler.
  • 4. EXAMPLE FOR EXAPANSION MACRO DEFINITION EXPANSIONOF MACRO Label field  A ,B , AREG are an actual parameters.  &MEM_VAL, &INC_VAL,&REG are formal parameters.
  • 5. Two key notions concerning macro expansion are A. Expansion time control flow : This determines the order in which model statements are visited during macro expansion. B. Lexical substitution: Lexical substitution is used to generate an assembly statement from a model statement.
  • 6. A. Flow of control during expansion  The default flow of control during macro expansion is sequential.  In the absence of preprocessor statements, the model statements of a macro are visited sequentially starting with the statement following the macro prototype statement and ending with the statement preceding the MEND statement.
  • 7. What can alter the flow of control during expansion? o A pre-processor statement can alter the flow of control during expansion such that o Conditional Expansion: Some model statements are either never visited during expansion, or Expansion Time Loops: are repeatedly visited during expansion. o The flow of control during macro expansion is implemented using a macro expansion counter (MEC)
  • 8. ALGORITHM (MACRO EXPANSION) 1. MEC:=statement number of first statement following the prototype statement. 2. While statement pointed by MEC is not a MEND statement. a. If a model statement then i. Expand the statement ii. MEC:=MEC+1; b. Else (i.e. a preprocessor statement) i. MEC:= new value specified in the statement. 3. Exit from macro expansion.
  • 9. B. LEXICAL SUBSTITUTION  A model statement consists of 3 types of strings.  An ordinary string, which stands for itself.  The name of a formal parameter which is preceded by the character „&‟.  The name of a pre-processor variable, which is also preceded by the character „&‟.  During lexical expansion, strings is retained in its original form .  The name of Formal parameter is replaced by its value from the actual parameter of a macro call.  The name of pre-processor variable is replaced with its value. This value is readily known to the pre-processor.
  • 10. Rules for determining the value of a formal parameter depends on the kind of parameter:  Positional Parameter  Keyword Parameter  Default specification of parameters  Macros with mixed parameter list  Other uses of parameter
  • 11. POSITIONAL PARAMETERS A positional formal parameter is written as &<parameter name> e.g. &SAMPLE where SAMPLE is the name of parameter. <parameter kind> of syntax rule is omitted. The value of a positional formal parameter XYZ is determined by the rule of positional association as follows: 1. Find the ordinal position of XYZ in the list of formal parameters in the macro prototype statement. 2. Find the actual parameter specification occupying the same ordinal position in the list of actual parameters in the macro call statement.
  • 12. Consider the call INCR A,B,AREG On macro INCR , following rule of positional association, values of formal parameters are: Formal parameter value MEM_VAL A INCR_VAL B REG AREG Lexical expansion of the model statements now leads to the code + MOVER AREG, A + ADD AREG, B + MOVEM AREG, A MACRO INCR &MEM_VAL,&INCR_VAL &REG MOVER &REG, &MEM_VAL ADD &REG, &INCR_VAL MOVEM &REG, &MEM_VAL MEND Consider the macro
  • 13. KEYWORD PARAMETER For keyword parameter, <parameter name> is an ordinary string and <parameter kind> is the string „=‟ in syntax rule. The <actual parameter spec> is written as<formal parameter name>=<ordinary string>. Note that the ordinal position of the specification XYZ=ABC in the list of actual parameters is immaterial. This is very useful in situations where long lists of parameters have to be used. Let us see example for it.
  • 14. Following are macro call statement: INCR_M MEM_VAL=A, INCR_VAL=B, REG=AREG ------ INCR_M INCR_VAL=B, REG=AREG, MEM_VAL=A Both are equivalent. Following is macro definition using keyword parameter: MACRO INCR_M &MEM_VAL=, &INCR_VAL=,&REG= MOVER &REG, &MEM_VAL ADD &REG, &INCR_VAL MOVEM &REG,&MEM_
  • 15. DEFAULT SPECIFICATIONS OF PARAMETERS A default value is a standard assumption in the absence of an explicit specification by the programmer. Default specification of parameters is useful in situations where a parameter has the same value in most calls. When the desired value is different from the default value, the desired value can be specified explicitly in a macro call. The syntax for formal parameter specification, as follows: &<parameter name> [<parameter kind> [<default value>]]
  • 16. EXAMPLE MACRO INCR_D &MEM_VAL=, &INCR_VAL=, &REG=AREG MOVER &REG, &MEM_VAL ADD &REG, &INCR_VAL MOVEM &REG, &MEM_VAL MEND The macro can be redefined to use a default specification for the parameter REG INCR_D MEM_VAL=A, INCR_VAL=B INCR_D INCR_VAL=B, MEM_VAL=A INCR_D INCR_VAL=B, MEM_VAL=A, REG=BREG First two calls are equivalent but third call overrides the default value for REG with the value BREG in next example.
  • 17. MACROS WITH MIXED PARAMETER LISTS A macro may be defined to use both positional and keyword parameters. In such a case, all positional parameters must precede all keyword parameters. example in the macro call SUM A, B, G=20, H=X A, B are positional parameters while G, H are keyword parameters. Correspondence between actual and formal parameters is established by applying the rules governing positional and keyword parameters separately.
  • 18. OTHER USES OF PARAMETERS The model statements have used formal parameters only in operand field. However, use of parameters is not restricted to these fields. Formal parameters can also appear in the label and opcode fields of model statements.
  • 19. NESTED MACRO CALLS  A model statement in a macro may constitute a call on another macro.  Such calls are known as nested macro calls.  Macro containing the nested call is the outer macro and, Macro called is inner macro.  They follow LIFO rule.  Thus, in structure of nested macro calls, expansion of latest macro call (i.e inner macro) is completed first.