SlideShare a Scribd company logo
1 of 20
G. H. Patel College of
Engineering & Technology
Subject : System Programming (2150708)
Topic : Macro Processor
Batch : 1D16
Prepared by:
Khyati Valera (160110116059)
Rutvi Vasani (160110116060)
Bhavik Vashi (160110116061)
Submitted to: Prof. Vinita Shah
What is 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
body of code.
▶ 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 : Example
MACRO -------- Start of definition
INCR -------- Macro name
A 1,DATA
A 2,DATA ------Sequence of instructions to be
A 3,DATA abbreviated
MEND -------- End of definition
Basic Macro Processor Functions
A program with
macro definition &
invocation
Macro
Processor
Program without
macro definition
Expanded
Program
Assembler
Object Program
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.
NESTED MACRO CALLS : Example
Source code
MACRO
ADD 1, &arg
L 1, &arg
A 1, = F ‘10’
ST 1, &arg
MEND
MACRO ADDS &arg1, &arg2, &arg3
ADD1 &arg1
ADD1 &arg2
ADD1 &arg3
MEND
ADDS data1, data2, data3
data 1 DC F‘5’
data 2 DC F‘6’
data 3 DC F‘7’
END
Expanded Code Level 1
Expansion of AADS
ADD1 data 1
ADD1 data 2
ADD1 data 3
data DC F ‘5’
data DC F ‘6’
data DC F ‘7’
END
Expanded Code Level 2
Expansion ofADD1
L 1, data 1
A 1, = F ’10’
ST 1, data 1
L 1, data 2
A 1, = F ’10’
ST 1, data 2
L 1, data 3
A 1, = F ’10’
ST 1, data 3
data1 DC F‘5’
data2 DC F‘6’
data3 DC F‘7’
END
Expanded Code Level 1
Expansion of AADS
ADD1 data 1
ADD1 data 2
ADD1 data 3
data DC F ‘5’
data DC F ‘6’
data DC F ‘7’
END
ADVANCED MACRO FACILITIES
▶ Advanced macro facilities are aimed to supporting semantic expansion.
▶ Used for:
▶ performing conditional expansion of model statements and
in writing expansion time loops.
▶ These facilities can be grouped into following.
▶ 1. Facilities for alteration of flow of control during expansion.
▶ 2. Expansion time variables.
▶ 3. Attributes of parameters.
AIF STATEMENT
▶ An AIF statement has the syntax
AIF (<expression>) <sequencing symbol>
▶ Where <expression> is a relational expression involving ordinary
strings, formal parameters and their attributes and expansion
time variables.
▶ If the relational expression evaluates to true, expansion time
control is transferred to the statement containing <sequencing
symbol> in its label field.
AIF STATEMENT : Example
MACRO
&N MOVE &T,&F
AIF (T'&T NE T'&F).END Statement 1
AIF (T'&T NE 'F').END Statement 2
&N ST 2,SAVEAREA Statement 3
L 2,&F
ST 2,&T
L 2,SAVEAREA
END MEND Statement 4
AGO STATEMENT
▶ An AGO statement has the syntax
AGO <sequencing symbol>
▶ Unconditionally transfers expansion time control to the
statement containing <sequencing symbol> in its label field.
AGO STATEMENT : Example
MACRO
&NAME MOVE &T,&F
AIF (T'&T EQ 'F').FIRST Statement
1
AGO .END
Statement 2
. FIRST AIF (T'&T NE T'&F).END Statement
3
&NAME ST 2,SAVEAREA
L 2,&F
ST 2,&T
L 2,SAVEAREA
.END MEND Statement
4
ANOP STATEMENT
▶ An ANOP statement is written as
<sequencing symbol> ANOP
▶ And simply has the effect of defining the sequencing symbol.
ANOP STATEMENT : Example
MACRO
&NAME MOVE &T,&F
LCLC &TYPE
AIF (T'&T EQ 'F').FTYPE Statement 1
&TYPE SETC 'E' Statement 2
.FTYPE ANOP Statement 3
&NAME ST&TYPE 2,SAVEAREA Statement 4
L&TYPE 2,&F
ST&TYPE 2,&T
L&TYPE 2,SAVEAREA
MEND
Algorithm : Pass 1
▶ Pass1 of macro processor makes a line-by-line scan over its input.
▶ Set MDTC = 1 as well as MNTC = 1.
▶ Read next line from input program.
▶ If it is a MACRO pseudo-op, the entire macro definition except this
(MACRO) line is stored in MDT.
▶ The name is entered into Macro Name Table along with a pointer to
the first location of MDT entry of the definition.
▶ When the END pseudo-op is encountered all the macro-definations
have been processed, so control is transferred to pass2
Algorithm : Pass 2
▶ This algorithm reads one line of input program at a time.
▶ for each Line it checks if op-code of that line matches any of the MNT entry.
▶ When match is found (i.e. when call is pointer called MDTF to corresponding
macro definition stored in MDT.
▶ The initial value of MDTP is obtained from MDT index field of MNT entry.
▶ The macro expander prepares the ALA consisting of a table of dummy
argument indices & corresponding arguments to the call.
▶ Reading proceeds from the MDT, as each successive line is read, The values
form the argument list one substituted for dummy arguments indices in the
macro defn.
▶ Reading MEND line in MDT terminates expansion of macro & scanning
continues from the input file.
▶ When END pseudo-op encountered , the expanded source program is given
to the assembler
MACRO PROCESSOR
MACRO PROCESSOR

More Related Content

What's hot (20)

Macro-processor
Macro-processorMacro-processor
Macro-processor
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
Loaders
LoadersLoaders
Loaders
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
 
Life cycle of a computer program
Life cycle of a computer programLife cycle of a computer program
Life cycle of a computer program
 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Macro assembler
 Macro assembler Macro assembler
Macro assembler
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
 
Compilers
CompilersCompilers
Compilers
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
Macro
MacroMacro
Macro
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 
Pass Structure of Assembler
Pass Structure of AssemblerPass Structure of Assembler
Pass Structure of Assembler
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
 

Similar to MACRO PROCESSOR

Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01riddhi viradiya
 
Presentation on macros and macro processor
Presentation on macros and macro processorPresentation on macros and macro processor
Presentation on macros and macro processorKuldeep Pathak
 
Power of call symput data
Power of call symput dataPower of call symput data
Power of call symput dataYash Sharma
 
CC week 1.pptx
CC week 1.pptxCC week 1.pptx
CC week 1.pptxkkjk4
 
Design of Predicate Filter for Predicated Branch Instructions
Design of Predicate Filter for Predicated Branch InstructionsDesign of Predicate Filter for Predicated Branch Instructions
Design of Predicate Filter for Predicated Branch InstructionsIOSR Journals
 
Fault Tolerant Parallel Filters Based On Bch Codes
Fault Tolerant Parallel Filters Based On Bch CodesFault Tolerant Parallel Filters Based On Bch Codes
Fault Tolerant Parallel Filters Based On Bch CodesIJERA Editor
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdfSemsemSameer1
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1venkatam
 
Emergency Service Provide by Mobile
Emergency Service Provide by MobileEmergency Service Provide by Mobile
Emergency Service Provide by MobileSamiul Hoque
 
SP Solutions -Adi.pdf
SP Solutions -Adi.pdfSP Solutions -Adi.pdf
SP Solutions -Adi.pdfAdiseshaK
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfAdiseshaK
 
Sas macros part 4.1
Sas macros part 4.1Sas macros part 4.1
Sas macros part 4.1venkatam
 
Summarizing Software API Usage Examples Using Clustering Techniques
Summarizing Software API Usage Examples Using Clustering TechniquesSummarizing Software API Usage Examples Using Clustering Techniques
Summarizing Software API Usage Examples Using Clustering TechniquesNikos Katirtzis
 

Similar to MACRO PROCESSOR (20)

Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01
 
Module 5.pdf
Module 5.pdfModule 5.pdf
Module 5.pdf
 
Presentation on macros and macro processor
Presentation on macros and macro processorPresentation on macros and macro processor
Presentation on macros and macro processor
 
handout6.pdf
handout6.pdfhandout6.pdf
handout6.pdf
 
Handout#05
Handout#05Handout#05
Handout#05
 
Power of call symput data
Power of call symput dataPower of call symput data
Power of call symput data
 
CC week 1.pptx
CC week 1.pptxCC week 1.pptx
CC week 1.pptx
 
C++ Constructs.pptx
C++ Constructs.pptxC++ Constructs.pptx
C++ Constructs.pptx
 
Design of Predicate Filter for Predicated Branch Instructions
Design of Predicate Filter for Predicated Branch InstructionsDesign of Predicate Filter for Predicated Branch Instructions
Design of Predicate Filter for Predicated Branch Instructions
 
Fault Tolerant Parallel Filters Based On Bch Codes
Fault Tolerant Parallel Filters Based On Bch CodesFault Tolerant Parallel Filters Based On Bch Codes
Fault Tolerant Parallel Filters Based On Bch Codes
 
Handout#04
Handout#04Handout#04
Handout#04
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1
 
Ss4
Ss4Ss4
Ss4
 
Emergency Service Provide by Mobile
Emergency Service Provide by MobileEmergency Service Provide by Mobile
Emergency Service Provide by Mobile
 
SP Solutions -Adi.pdf
SP Solutions -Adi.pdfSP Solutions -Adi.pdf
SP Solutions -Adi.pdf
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdf
 
SP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdfSP_Solutions_-Adi.pdf
SP_Solutions_-Adi.pdf
 
Sas macros part 4.1
Sas macros part 4.1Sas macros part 4.1
Sas macros part 4.1
 
Summarizing Software API Usage Examples Using Clustering Techniques
Summarizing Software API Usage Examples Using Clustering TechniquesSummarizing Software API Usage Examples Using Clustering Techniques
Summarizing Software API Usage Examples Using Clustering Techniques
 

More from Bhavik Vashi

Runge Kutta Method
Runge Kutta Method Runge Kutta Method
Runge Kutta Method Bhavik Vashi
 
Rate monotonic scheduling- Operating System
Rate monotonic scheduling- Operating SystemRate monotonic scheduling- Operating System
Rate monotonic scheduling- Operating SystemBhavik Vashi
 
Data Structure Radix Sort
Data Structure Radix SortData Structure Radix Sort
Data Structure Radix SortBhavik Vashi
 
File management in OS
File management in OSFile management in OS
File management in OSBhavik Vashi
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++Bhavik Vashi
 
Parallel processing (simd and mimd)
Parallel processing (simd and mimd)Parallel processing (simd and mimd)
Parallel processing (simd and mimd)Bhavik Vashi
 
Ethernet and switches
Ethernet and switchesEthernet and switches
Ethernet and switchesBhavik Vashi
 
Fiscal Policy & Monetary Policy
Fiscal Policy & Monetary PolicyFiscal Policy & Monetary Policy
Fiscal Policy & Monetary PolicyBhavik Vashi
 
Projection of lines
Projection of linesProjection of lines
Projection of linesBhavik Vashi
 
Most Successful People & Personality
Most Successful People & Personality Most Successful People & Personality
Most Successful People & Personality Bhavik Vashi
 
Global Need of the World
Global Need of the WorldGlobal Need of the World
Global Need of the WorldBhavik Vashi
 
Functions of stdio conio
Functions of stdio   conio Functions of stdio   conio
Functions of stdio conio Bhavik Vashi
 
Impact of social media
Impact of social mediaImpact of social media
Impact of social mediaBhavik Vashi
 

More from Bhavik Vashi (20)

Aws ec2
Aws ec2Aws ec2
Aws ec2
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Linear Sorting
Linear SortingLinear Sorting
Linear Sorting
 
Colormodels
ColormodelsColormodels
Colormodels
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Runge Kutta Method
Runge Kutta Method Runge Kutta Method
Runge Kutta Method
 
Rate monotonic scheduling- Operating System
Rate monotonic scheduling- Operating SystemRate monotonic scheduling- Operating System
Rate monotonic scheduling- Operating System
 
Data Structure Radix Sort
Data Structure Radix SortData Structure Radix Sort
Data Structure Radix Sort
 
File management in OS
File management in OSFile management in OS
File management in OS
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++
 
Parallel processing (simd and mimd)
Parallel processing (simd and mimd)Parallel processing (simd and mimd)
Parallel processing (simd and mimd)
 
Ethernet and switches
Ethernet and switchesEthernet and switches
Ethernet and switches
 
Fiscal Policy & Monetary Policy
Fiscal Policy & Monetary PolicyFiscal Policy & Monetary Policy
Fiscal Policy & Monetary Policy
 
Diwali Light
Diwali LightDiwali Light
Diwali Light
 
Heat transfer
Heat transferHeat transfer
Heat transfer
 
Projection of lines
Projection of linesProjection of lines
Projection of lines
 
Most Successful People & Personality
Most Successful People & Personality Most Successful People & Personality
Most Successful People & Personality
 
Global Need of the World
Global Need of the WorldGlobal Need of the World
Global Need of the World
 
Functions of stdio conio
Functions of stdio   conio Functions of stdio   conio
Functions of stdio conio
 
Impact of social media
Impact of social mediaImpact of social media
Impact of social media
 

Recently uploaded

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
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
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
 
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
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
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
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
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
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
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
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
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
 

Recently uploaded (20)

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
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
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
 
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
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
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
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.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
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
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
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
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)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
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
 

MACRO PROCESSOR

  • 1. G. H. Patel College of Engineering & Technology Subject : System Programming (2150708) Topic : Macro Processor Batch : 1D16 Prepared by: Khyati Valera (160110116059) Rutvi Vasani (160110116060) Bhavik Vashi (160110116061) Submitted to: Prof. Vinita Shah
  • 2. What is 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 body of code. ▶ 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 : Example MACRO -------- Start of definition INCR -------- Macro name A 1,DATA A 2,DATA ------Sequence of instructions to be A 3,DATA abbreviated MEND -------- End of definition
  • 4. Basic Macro Processor Functions A program with macro definition & invocation Macro Processor Program without macro definition Expanded Program Assembler Object Program
  • 5. 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.
  • 6. NESTED MACRO CALLS : Example
  • 7. Source code MACRO ADD 1, &arg L 1, &arg A 1, = F ‘10’ ST 1, &arg MEND MACRO ADDS &arg1, &arg2, &arg3 ADD1 &arg1 ADD1 &arg2 ADD1 &arg3 MEND ADDS data1, data2, data3 data 1 DC F‘5’ data 2 DC F‘6’ data 3 DC F‘7’ END Expanded Code Level 1 Expansion of AADS ADD1 data 1 ADD1 data 2 ADD1 data 3 data DC F ‘5’ data DC F ‘6’ data DC F ‘7’ END
  • 8. Expanded Code Level 2 Expansion ofADD1 L 1, data 1 A 1, = F ’10’ ST 1, data 1 L 1, data 2 A 1, = F ’10’ ST 1, data 2 L 1, data 3 A 1, = F ’10’ ST 1, data 3 data1 DC F‘5’ data2 DC F‘6’ data3 DC F‘7’ END Expanded Code Level 1 Expansion of AADS ADD1 data 1 ADD1 data 2 ADD1 data 3 data DC F ‘5’ data DC F ‘6’ data DC F ‘7’ END
  • 9. ADVANCED MACRO FACILITIES ▶ Advanced macro facilities are aimed to supporting semantic expansion. ▶ Used for: ▶ performing conditional expansion of model statements and in writing expansion time loops. ▶ These facilities can be grouped into following. ▶ 1. Facilities for alteration of flow of control during expansion. ▶ 2. Expansion time variables. ▶ 3. Attributes of parameters.
  • 10. AIF STATEMENT ▶ An AIF statement has the syntax AIF (<expression>) <sequencing symbol> ▶ Where <expression> is a relational expression involving ordinary strings, formal parameters and their attributes and expansion time variables. ▶ If the relational expression evaluates to true, expansion time control is transferred to the statement containing <sequencing symbol> in its label field.
  • 11. AIF STATEMENT : Example MACRO &N MOVE &T,&F AIF (T'&T NE T'&F).END Statement 1 AIF (T'&T NE 'F').END Statement 2 &N ST 2,SAVEAREA Statement 3 L 2,&F ST 2,&T L 2,SAVEAREA END MEND Statement 4
  • 12. AGO STATEMENT ▶ An AGO statement has the syntax AGO <sequencing symbol> ▶ Unconditionally transfers expansion time control to the statement containing <sequencing symbol> in its label field.
  • 13. AGO STATEMENT : Example MACRO &NAME MOVE &T,&F AIF (T'&T EQ 'F').FIRST Statement 1 AGO .END Statement 2 . FIRST AIF (T'&T NE T'&F).END Statement 3 &NAME ST 2,SAVEAREA L 2,&F ST 2,&T L 2,SAVEAREA .END MEND Statement 4
  • 14. ANOP STATEMENT ▶ An ANOP statement is written as <sequencing symbol> ANOP ▶ And simply has the effect of defining the sequencing symbol.
  • 15. ANOP STATEMENT : Example MACRO &NAME MOVE &T,&F LCLC &TYPE AIF (T'&T EQ 'F').FTYPE Statement 1 &TYPE SETC 'E' Statement 2 .FTYPE ANOP Statement 3 &NAME ST&TYPE 2,SAVEAREA Statement 4 L&TYPE 2,&F ST&TYPE 2,&T L&TYPE 2,SAVEAREA MEND
  • 16. Algorithm : Pass 1 ▶ Pass1 of macro processor makes a line-by-line scan over its input. ▶ Set MDTC = 1 as well as MNTC = 1. ▶ Read next line from input program. ▶ If it is a MACRO pseudo-op, the entire macro definition except this (MACRO) line is stored in MDT. ▶ The name is entered into Macro Name Table along with a pointer to the first location of MDT entry of the definition. ▶ When the END pseudo-op is encountered all the macro-definations have been processed, so control is transferred to pass2
  • 17.
  • 18. Algorithm : Pass 2 ▶ This algorithm reads one line of input program at a time. ▶ for each Line it checks if op-code of that line matches any of the MNT entry. ▶ When match is found (i.e. when call is pointer called MDTF to corresponding macro definition stored in MDT. ▶ The initial value of MDTP is obtained from MDT index field of MNT entry. ▶ The macro expander prepares the ALA consisting of a table of dummy argument indices & corresponding arguments to the call. ▶ Reading proceeds from the MDT, as each successive line is read, The values form the argument list one substituted for dummy arguments indices in the macro defn. ▶ Reading MEND line in MDT terminates expansion of macro & scanning continues from the input file. ▶ When END pseudo-op encountered , the expanded source program is given to the assembler