SlideShare a Scribd company logo
1 of 31
MACRO
First Macro Example:- #include <stdio.h> #define SquareOf(x) x*x void main() { int xin=3; printf(&quot;xin=%i&quot;,xin); printf(&quot;SquareOf(xin)=%i&quot;, SquareOf(xin) ); printf(&quot;SquareOf(xin+4)=%i&quot;, SquareOf(xin+4) ); printf(&quot;SquareOf(xin+xin)=%i&quot;, SquareOf(xin+xin) ); }
C Program for Swapping:- #include<stdio.h> void exchange(int i, int j) { int temp; temp = i; i = j; j = temp; printf(&quot;AFTER - %d %d&quot;, i, j); } main() { int i=1, j=3; printf(&quot;BEFORE - %d %d&quot;, i, j); exchange(i, j); }
Macro for Swapping:- #include<stdio.h> #define swap(i,j) { int temp; temp=i; i=j; j=temp; } void main() { int i=1, j=3; printf(&quot;BEFORE - %d %d&quot;, i, j); swap(i,j); printf(&quot;AFTER - %d %d&quot;, i, j); }
Macro:- A macro is a unit of specification for program generation through expansion. A macro consists of a name, a set of formal parameters and a body of code. The use of macro name with a set of actual parameters is replaced by code generated from its body.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Macro header & End stmt
ADVANCED MACRO FACILITIES ,[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],REPRESENTING   SS If condition is true ( Y= X) then control will be transferred to  .ONLY
Expansion time variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example of EV ,[object Object],[object Object],[object Object],[object Object],[object Object]
Attributes of parameters An attribute is written using the syntax:- <attribute name>  ’  <formal parameter specification> T– type L – length S – size Example MACRO ME &A AIF  (L’&A EQ 1) .NEXT ------ -----
ALGORITHM OF MACRO PROCESSOR
EXAMPLE MACRO TEST &X, &N, &R=AREG LCL  &M &M SET  0 .PQ MOVEM &R, &X+&M &M SET  &M + 1 AIF (&M NE N) .PQ MEND
EXAMPLE MACRO TEST & X , & N ,  R =AREG LCL  & M   &M SET  0 .PQ MOVEM &R, &X+&M &M SET  &M + 1 AIF (&M NE N) .PQ MEND MACRO CALL TEST  S,10 REPRESENTS PARAMETER NAME REPRESENTS EXPAN. VAR.  NAME REPRESENTS SEQUENCING SYMBOL  NAME REPRESENTS ACTUAL PARAMETER  NAME
Tables of Macro Preprocessor ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tables of Macro Preprocessor ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tables of Macro Preprocessor 7.  Actual Parameter Table (APT) FIELDS :- a) Value 8.  EV Table (EVTAB) FIELDS:- a) value 9.  SS Table (SSTAB) FIELDS :- a) MDT Entry #
EXAMPLE MACRO TEST & X , & N ,  R =AREG LCL  & M   &M SET  0 .PQ MOVEM &R, &X+&M &M SET  &M + 1 AIF (&M NE N) .PQ MEND MACRO CALL TEST  S,10 REPRESENTS PARAMETER NAME REPRESENTS EXPAN. VAR.  NAME REPRESENTS SEQUENCING SYMBOL  NAME REPRESENTS ACTUAL PARAMETER  NAME
PNTAB EVNTAB KPDTAB SSNTAB APTAB EVTAB SSTAB R N X M AREG R PQ AREG 10 S 0 27
MNT MDT SSTP KPDTP MDTP #EV #KP #PP Name 5 10 25 1 1 2 TEST 30 29 28 27 26 25 MEND AIF  (E,1) NE (P,2) (S,1) (E,1)  SET  (E,1) +1 MOVEM (P,3),(P,1)+(E,1) (E,1)  SET  0 LCL (E,1)
Steps for MNT Entry TEST & X , & N ,  R= AREG STRUCTURE OF MNT For each positional parameter (i) Enter  Parameter name in  PNTAB [PNTAB_ptr] (ii)PNTAB_ptr := PNTAB_Ptr + 1; (iii)# PP := # PP + 1 : PNTAB x #pp=1 N #pp=1+1=2 SSTP KPDTP MDTP #EV #KP #PP Name
Steps for MNT Entry TEST & X , & N ,  R= AREG STRUCTURE OF MNT 10 PNTAB For each keyword parameter (i)Enter  parameter name and default value  ( if any), in KPDTAB   (ii) Enter parameter name  in PNTAB [ PNTAB_Ptr}. (iii) KPDTAB_Ptr := KPDTAB _Ptr + 1 ; (iv) PNTAB_Ptr := PNTAB_Ptr  + 1; (v)# KP := # KP + 1 ; KPDTAB R R,  AREG # KP := 1 N x AREG R SSTP KPDTP MDTP #EV #KP #PP Name
MDT 5 SSTAB MNT 30 29 28 27 26 25 MEND AIF  (E,1) NE (P,2) (S,1) (E,1)  SET  (E,1) +1 MOVEM (P,3),(P,1)+(E,1) (E,1)  SET  0 LCL (E,1) 27 SSTP KPDTP MDTP #EV #KP #PP Name 5 10 25 1 1 2 TEST
LCL  & M EVNTAB M If an LCL statement then (i) Enter expansion time variable name in EVNTAB  (ii)# EV := # EV + 1 ; M
.PQ MOVEM &R, &X+&M SSNTAB a)  If  SS is present in SSNTAB then get index No. Else 1 Enter SS in SSNTAB, then get index No. and  2. Enter MDT_Ptr in SSTAB b) For a parameter , generate the specification ( p,#n). c) For an expansion variable,generate the  specification ( E, # m). . PQ SSTAB 5 27 .PQ MOVEM &R, &X+&M MOVEM  (P,3) , (P,1)+(E,1) Enter this line into MDT Steps for Model Stmt
(Processing of a macro definition) 1.  SSNTAB_Ptr :=1; SSTAB_PTR:=1;MDT_ptr:=1; PNTAB_ptr :=1;KPDTAB_PTR:=1; 2.  Process the macro prototype statement and from the MNT entry  (a)  name  := macro name ; (b) For each positional parameter (i)  Enter  Parameter name in  PNTAB [PNTAB_ptr] (ii)  PNTAB_ptr := PNTAB_Ptr + 1; (iii) # PP := # PP + 1 : (c) KPDTP := KPDTAB_ ptr ; (d) For each keyword parameter (i)Enter  parameter name and default value  ( if any), in  KPDTAB [KPDTAB_ptr + 1]; (ii) Enter parameter name  in PNTAB [ PNTAB_Ptr}. (iii) KPDTAB_Ptr := KPDTAB _Ptr + 1 ; (iv) PNTAB_Ptr := PNTAB_Ptr  + 1; (v) # KP := # KP + 1 ; (e) MDTP :=  MDT_Ptr, (f) #EV := 0 ; (g) SSTP :=  SSTAB_Ptr  ;
3. While not a MEND statement (a) If an LCL statement then (i)  Enter expansion time variable name in EVNTAB  (ii) # EV := # EV + 1 ; (b) If a model statement then (i) If a label field contains a sequencing symbol then If symbol is present in SSNTAB then q := entry number in SSNTAB;   else Enter symbol in SSNTAB [ SSNTAB_Ptr]. q:= SSNTAB_Ptr; SSNTAB_ptr := SSNTAB_Ptr + 1; SSTAB [ SSTP + q – 1] := MDT_ Ptr; (ii) For a parameter , generate the specification ( p,#n). (iii) For an expansion variable,generate the  specification ( E, # m). (iv) Record the IC in MDT [ MDt_ptr]; (v) MDT_Ptr := MDT_Ptr + 1 :
(c ) If a preprocessor statement then (i) If a SET statement Search each expansion time variable  name used in the statement in EVNTAB  and generate (E,#m) (ii) If an AIF  or Ago statement then If sequencing symbol used in the  statement is present is SSNTAB then q = entry number in SSNTAB else Enter symbol in SSNTAB [ SSNTAB _ Ptr] q :=  SSNTABPtr ; SSNTAB_ Ptr := SSNTAB_ Ptr + 1 : Replace the symbol by ( S, SSTP + q – 1 ) (iii) Record the  IC in MDT [MDT_Ptr]. (iv) MDT_Ptr := MDT_ Ptr + 1 :
4. (MEND Statement ) If SSNTAB_Ptr = 1 ( i,e, SSNTAB is empty ) then SSTP := 0; Else SSTAB_Ptr := SSTAB_ Ptr + SSNYAB_Ptr – 1 : If # KP = 0 then KPDTP =0;

More Related Content

What's hot

System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
Manoj Patil
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
Manoj Patil
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
guest9f8315
 

What's hot (20)

System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
 
System software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSystem software - macro expansion,nested macro calls
System software - macro expansion,nested macro calls
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
Pass Structure of Assembler
Pass Structure of AssemblerPass Structure of Assembler
Pass Structure of Assembler
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 
Toy compiler
Toy compilerToy compiler
Toy compiler
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
 
Macro
MacroMacro
Macro
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
 
Interactive debugging system
Interactive debugging systemInteractive debugging system
Interactive debugging system
 
Three Address code
Three Address code Three Address code
Three Address code
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Assembler - System Programming
Assembler - System ProgrammingAssembler - System Programming
Assembler - System Programming
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Code Generation
Code GenerationCode Generation
Code Generation
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 

Similar to Macro

Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
wingsrai
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01
tabish
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01
tabish
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
tabish
 
PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & PinbaPHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
Patrick Allaert
 

Similar to Macro (20)

Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
 
U3.pptx
U3.pptxU3.pptx
U3.pptx
 
unit 3 ppt.pptx
unit 3 ppt.pptxunit 3 ppt.pptx
unit 3 ppt.pptx
 
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework Help
 
QTP Presentation2
QTP Presentation2QTP Presentation2
QTP Presentation2
 
L7 pointers
L7 pointersL7 pointers
L7 pointers
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01
 
Chapter 1 Abap Programming Overview
Chapter 1 Abap Programming OverviewChapter 1 Abap Programming Overview
Chapter 1 Abap Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & PinbaPHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)
Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)
Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)
 
ATE Pattern Structure Basics
ATE Pattern Structure BasicsATE Pattern Structure Basics
ATE Pattern Structure Basics
 
Unit3 C
Unit3 C Unit3 C
Unit3 C
 
R console
R consoleR console
R console
 
iit c prog.ppt
iit c prog.pptiit c prog.ppt
iit c prog.ppt
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Macro

  • 2. First Macro Example:- #include <stdio.h> #define SquareOf(x) x*x void main() { int xin=3; printf(&quot;xin=%i&quot;,xin); printf(&quot;SquareOf(xin)=%i&quot;, SquareOf(xin) ); printf(&quot;SquareOf(xin+4)=%i&quot;, SquareOf(xin+4) ); printf(&quot;SquareOf(xin+xin)=%i&quot;, SquareOf(xin+xin) ); }
  • 3. C Program for Swapping:- #include<stdio.h> void exchange(int i, int j) { int temp; temp = i; i = j; j = temp; printf(&quot;AFTER - %d %d&quot;, i, j); } main() { int i=1, j=3; printf(&quot;BEFORE - %d %d&quot;, i, j); exchange(i, j); }
  • 4. Macro for Swapping:- #include<stdio.h> #define swap(i,j) { int temp; temp=i; i=j; j=temp; } void main() { int i=1, j=3; printf(&quot;BEFORE - %d %d&quot;, i, j); swap(i,j); printf(&quot;AFTER - %d %d&quot;, i, j); }
  • 5. Macro:- A macro is a unit of specification for program generation through expansion. A macro consists of a name, a set of formal parameters and a body of code. The use of macro name with a set of actual parameters is replaced by code generated from its body.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. Attributes of parameters An attribute is written using the syntax:- <attribute name> ’ <formal parameter specification> T– type L – length S – size Example MACRO ME &A AIF (L’&A EQ 1) .NEXT ------ -----
  • 14. ALGORITHM OF MACRO PROCESSOR
  • 15. EXAMPLE MACRO TEST &X, &N, &R=AREG LCL &M &M SET 0 .PQ MOVEM &R, &X+&M &M SET &M + 1 AIF (&M NE N) .PQ MEND
  • 16. EXAMPLE MACRO TEST & X , & N , R =AREG LCL & M &M SET 0 .PQ MOVEM &R, &X+&M &M SET &M + 1 AIF (&M NE N) .PQ MEND MACRO CALL TEST S,10 REPRESENTS PARAMETER NAME REPRESENTS EXPAN. VAR. NAME REPRESENTS SEQUENCING SYMBOL NAME REPRESENTS ACTUAL PARAMETER NAME
  • 17.
  • 18.
  • 19. Tables of Macro Preprocessor 7. Actual Parameter Table (APT) FIELDS :- a) Value 8. EV Table (EVTAB) FIELDS:- a) value 9. SS Table (SSTAB) FIELDS :- a) MDT Entry #
  • 20. EXAMPLE MACRO TEST & X , & N , R =AREG LCL & M &M SET 0 .PQ MOVEM &R, &X+&M &M SET &M + 1 AIF (&M NE N) .PQ MEND MACRO CALL TEST S,10 REPRESENTS PARAMETER NAME REPRESENTS EXPAN. VAR. NAME REPRESENTS SEQUENCING SYMBOL NAME REPRESENTS ACTUAL PARAMETER NAME
  • 21. PNTAB EVNTAB KPDTAB SSNTAB APTAB EVTAB SSTAB R N X M AREG R PQ AREG 10 S 0 27
  • 22. MNT MDT SSTP KPDTP MDTP #EV #KP #PP Name 5 10 25 1 1 2 TEST 30 29 28 27 26 25 MEND AIF (E,1) NE (P,2) (S,1) (E,1) SET (E,1) +1 MOVEM (P,3),(P,1)+(E,1) (E,1) SET 0 LCL (E,1)
  • 23. Steps for MNT Entry TEST & X , & N , R= AREG STRUCTURE OF MNT For each positional parameter (i) Enter Parameter name in PNTAB [PNTAB_ptr] (ii)PNTAB_ptr := PNTAB_Ptr + 1; (iii)# PP := # PP + 1 : PNTAB x #pp=1 N #pp=1+1=2 SSTP KPDTP MDTP #EV #KP #PP Name
  • 24. Steps for MNT Entry TEST & X , & N , R= AREG STRUCTURE OF MNT 10 PNTAB For each keyword parameter (i)Enter parameter name and default value ( if any), in KPDTAB (ii) Enter parameter name in PNTAB [ PNTAB_Ptr}. (iii) KPDTAB_Ptr := KPDTAB _Ptr + 1 ; (iv) PNTAB_Ptr := PNTAB_Ptr + 1; (v)# KP := # KP + 1 ; KPDTAB R R, AREG # KP := 1 N x AREG R SSTP KPDTP MDTP #EV #KP #PP Name
  • 25. MDT 5 SSTAB MNT 30 29 28 27 26 25 MEND AIF (E,1) NE (P,2) (S,1) (E,1) SET (E,1) +1 MOVEM (P,3),(P,1)+(E,1) (E,1) SET 0 LCL (E,1) 27 SSTP KPDTP MDTP #EV #KP #PP Name 5 10 25 1 1 2 TEST
  • 26. LCL & M EVNTAB M If an LCL statement then (i) Enter expansion time variable name in EVNTAB (ii)# EV := # EV + 1 ; M
  • 27. .PQ MOVEM &R, &X+&M SSNTAB a) If SS is present in SSNTAB then get index No. Else 1 Enter SS in SSNTAB, then get index No. and 2. Enter MDT_Ptr in SSTAB b) For a parameter , generate the specification ( p,#n). c) For an expansion variable,generate the specification ( E, # m). . PQ SSTAB 5 27 .PQ MOVEM &R, &X+&M MOVEM (P,3) , (P,1)+(E,1) Enter this line into MDT Steps for Model Stmt
  • 28. (Processing of a macro definition) 1. SSNTAB_Ptr :=1; SSTAB_PTR:=1;MDT_ptr:=1; PNTAB_ptr :=1;KPDTAB_PTR:=1; 2. Process the macro prototype statement and from the MNT entry (a) name := macro name ; (b) For each positional parameter (i) Enter Parameter name in PNTAB [PNTAB_ptr] (ii) PNTAB_ptr := PNTAB_Ptr + 1; (iii) # PP := # PP + 1 : (c) KPDTP := KPDTAB_ ptr ; (d) For each keyword parameter (i)Enter parameter name and default value ( if any), in KPDTAB [KPDTAB_ptr + 1]; (ii) Enter parameter name in PNTAB [ PNTAB_Ptr}. (iii) KPDTAB_Ptr := KPDTAB _Ptr + 1 ; (iv) PNTAB_Ptr := PNTAB_Ptr + 1; (v) # KP := # KP + 1 ; (e) MDTP := MDT_Ptr, (f) #EV := 0 ; (g) SSTP := SSTAB_Ptr ;
  • 29. 3. While not a MEND statement (a) If an LCL statement then (i) Enter expansion time variable name in EVNTAB (ii) # EV := # EV + 1 ; (b) If a model statement then (i) If a label field contains a sequencing symbol then If symbol is present in SSNTAB then q := entry number in SSNTAB; else Enter symbol in SSNTAB [ SSNTAB_Ptr]. q:= SSNTAB_Ptr; SSNTAB_ptr := SSNTAB_Ptr + 1; SSTAB [ SSTP + q – 1] := MDT_ Ptr; (ii) For a parameter , generate the specification ( p,#n). (iii) For an expansion variable,generate the specification ( E, # m). (iv) Record the IC in MDT [ MDt_ptr]; (v) MDT_Ptr := MDT_Ptr + 1 :
  • 30. (c ) If a preprocessor statement then (i) If a SET statement Search each expansion time variable name used in the statement in EVNTAB and generate (E,#m) (ii) If an AIF or Ago statement then If sequencing symbol used in the statement is present is SSNTAB then q = entry number in SSNTAB else Enter symbol in SSNTAB [ SSNTAB _ Ptr] q := SSNTABPtr ; SSNTAB_ Ptr := SSNTAB_ Ptr + 1 : Replace the symbol by ( S, SSTP + q – 1 ) (iii) Record the IC in MDT [MDT_Ptr]. (iv) MDT_Ptr := MDT_ Ptr + 1 :
  • 31. 4. (MEND Statement ) If SSNTAB_Ptr = 1 ( i,e, SSNTAB is empty ) then SSTP := 0; Else SSTAB_Ptr := SSTAB_ Ptr + SSNYAB_Ptr – 1 : If # KP = 0 then KPDTP =0;