SlideShare une entreprise Scribd logo
1  sur  9
Télécharger pour lire hors ligne
QUESTION BANK
UNIT IV

CS 1203 SYSTEM SOFTWARE
UNIT-III MACRO PROCESSORS

MACRO PROCESSORS

9

Basic macro processor functions - Macro Definition and Expansion – Macro Processor Algorithm
and data structures - Machine-independent macro processor features - Concatenation of Macro
Parameters – Generation of Unique Labels – Conditional Macro Expansion – Keyword Macro
Parameters-Macro within Macro-Implementation example - MASM Macro Processor – ANSI C
Macro language.

1) Define Macro.
A macro instruction (macro) is a notational convenience for the programmer.
It allows the programmer to write a shorthand version of a program
o A macro represents a commonly used group of statements in the
source programming language.
o Expanding the macros - the macro processor replaces each macro
instruction with the corresponding group of source language
statements.
2) What is a macro processor?
A macro processor - Essentially involve the substitution of one group
of characters or lines for another. Normally, it performs no analysis of the text it
handles. It doesn’t concern the meaning of the involved statements during macro
expansion
o The design of a macro processor generally is machine independent.
Three examples of actual macro processors:
o A macro processor designed for use by assembler language programmers
o Used with a high-level programming language
o General-purpose macro processor, which is not tied to any particular
language

3) What are the basic macro processor functions?
Basic Macro Processors Functions
Macro processor should processes the
Macro definitions
o Define macro name, group of instructions
Macro invocation (macro calls)
o A body is simply copied or substituted at the point of call Expansion with
substitution of parameters
o Arguments are textually substituted for the parameters
o The resulting procedure body is textually substituted for the call
4) What are the Assembler directives used for Macro Definition?
Macro Definition
Two new assembler directives are used in macro definition:
MACRO: identify the beginning of a macro definition
MEND: identify the end of a macro definition
o label op operands
name MACRO parameters
:
body
:
MEND
o Parameters: the entries in the operand field identify the parameters of the macro
instruction
We require each parameter begins with ‘&’
o Body: the statements that will be generated as the expansion of the macro.
o Prototype for the macro:
The macro name and parameters define a pattern or prototype for the macro
instructions used by the programmer
5) Give an example program which uses Macro Definition.
Macro Definition
6) How Macro is invoked in a program? Give example.

Macro Invocation
7) What is Macro Expansion? Give an example.

Macro Expansion
Each macro invocation statement will be expanded into the statements that form
the body of the macro.
o Arguments from the macro invocation are substituted for the parameters in
the macro prototype.
The arguments and parameters are associated with one another according to
their positions.
o The first argument in the macro invocation corresponds to the first
parameter in the macro prototype, etc.

Macro Expansion Example

Program From Fig. 4.1 with Macros Expanded (fig. 4.2)(Cont.)

8)Explain the functions of two pass macro processor.
Two-pass macro processor
o Two-pass macro processor
o Pass1: process all macro definitions
o Pass2: expand all macro invocation statements
o Problem
Does not allow nested macro definitions
o Nested macro definitions
o The body of a macro contains definitions of other macros
Because all macros would have to be defined during the
first pass before any macro invocations were expanded
o Solution
• One-pass macro processor
9) What is the characteristic of one pass macro processor?
One-pass macro processor
Every macro must be defined before it is called
One-pass processor can alternate between macrodefinition and macro
expansion
Nested macro definitions are allowed
10) What are the data structures used by the macro processor?
Data Structures
o MACRO DEFINITION TABLE (DEFTAB)
Macro prototype
States that make up the macro body
Reference to parameters are converted to a positional notation.
o MACRO NAME TABLE (NAMTAB)
Role: an index to DEFTAB
Pointers to the beginning and end of the definition in DEFTAB
o MACRO ARGUMENT TABLE (ARGTAB)
Used during the expansion
Invocation  Arguments are stored in ARGTAB according to their
position
11) Write an algorithm for the Macro processor and explain.
Algorithm and Data Structure (4)
12) What is the difference between a Macro and a subroutine?
Differences between Macro and Subroutine
After macro processing, the expanded file can be used as input to the
assembler.
The statements generated from the macro expansions will be assembled
exactly as though they had been written directly by the programmer.
The differences between macro invocation and subroutine call
o The statements that form the body of the macro are generated each
time a macro is expanded.
o Statements in a subroutine appear only once, regardless of how many
times the subroutine is called.
13) What are the machine independent features of macro processors?
Other Macro Features
Concatenation of macro parameters
Generation of unique labels
Conditional macro expansion
Keyword Macro Parameters
Concatenation of Macro Parameters
Pre-concatenation
o LDA X&ID1
Post-concatenation
o LDA X&ID→1
Example: Figure 4.6
Concatenation Example

Generation of Unique Labels
Example
o JEQ *-3
o inconvenient, error-prone, difficult to read
Example Figure 4.7
$LOOP
TD
=X’&INDEV’
o 1st call:
$AALOOP TD
=X’F1’
o 2nd call:
$ABLOOP

RDBUFF

F1, BUFFER, LENGTH

TD

=X’F1’

Contenu connexe

Tendances

Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
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 callsSARASWATHI S
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming ) Adarsh Patel
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03desta_gebre
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language ProcessingHemant Sharma
 
Translation of expression(copmiler construction)
Translation of expression(copmiler construction)Translation of expression(copmiler construction)
Translation of expression(copmiler construction)IrtazaAfzal3
 
Macros in system programing
Macros in system programingMacros in system programing
Macros in system programingBrijesh__patel
 

Tendances (20)

Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Spr ch-02
Spr ch-02Spr ch-02
Spr ch-02
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
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
 
Language processors
Language processorsLanguage processors
Language processors
 
Assembler
AssemblerAssembler
Assembler
 
Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchart
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
 
Unit 3
Unit 3Unit 3
Unit 3
 
Translation of expression(copmiler construction)
Translation of expression(copmiler construction)Translation of expression(copmiler construction)
Translation of expression(copmiler construction)
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
Macros in system programing
Macros in system programingMacros in system programing
Macros in system programing
 
Assemblers
AssemblersAssemblers
Assemblers
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
Macro assembler
 Macro assembler Macro assembler
Macro assembler
 

Similaire à 33443223 system-software-unit-iv

Sas macros part 4.1
Sas macros part 4.1Sas macros part 4.1
Sas macros part 4.1venkatam
 
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.pdfacsmadurai
 
Macros...presentation
Macros...presentationMacros...presentation
Macros...presentationfika sweety
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c languagetanmaymodi4
 
Preprocessor directives in c laguage
Preprocessor directives in c laguagePreprocessor directives in c laguage
Preprocessor directives in c laguageTanmay Modi
 
BAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureBAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureWake Tech BAS
 
Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01riddhi viradiya
 
N_Asm Assembly macros (sol)
N_Asm Assembly macros (sol)N_Asm Assembly macros (sol)
N_Asm Assembly macros (sol)Selomon birhane
 
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
 
system prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdfsystem prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdfSATHYABAMAMADHANKUMA
 

Similaire à 33443223 system-software-unit-iv (20)

Module 5.pdf
Module 5.pdfModule 5.pdf
Module 5.pdf
 
handout6.pdf
handout6.pdfhandout6.pdf
handout6.pdf
 
Ss4
Ss4Ss4
Ss4
 
Sas macros part 4.1
Sas macros part 4.1Sas macros part 4.1
Sas macros part 4.1
 
Handout#04
Handout#04Handout#04
Handout#04
 
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
 
Handout#05
Handout#05Handout#05
Handout#05
 
MACRO ASSEBLER
MACRO ASSEBLERMACRO ASSEBLER
MACRO ASSEBLER
 
Macros...presentation
Macros...presentationMacros...presentation
Macros...presentation
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
 
Preprocessor directives in c laguage
Preprocessor directives in c laguagePreprocessor directives in c laguage
Preprocessor directives in c laguage
 
BAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureBAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 Lecture
 
Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01Unit ii-111206004636-phpapp01
Unit ii-111206004636-phpapp01
 
N_Asm Assembly macros (sol)
N_Asm Assembly macros (sol)N_Asm Assembly macros (sol)
N_Asm Assembly macros (sol)
 
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
 
PreProcessorDirective.ppt
PreProcessorDirective.pptPreProcessorDirective.ppt
PreProcessorDirective.ppt
 
VBA
VBAVBA
VBA
 
system prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdfsystem prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdf
 

Dernier

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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 slidevu2urc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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...Enterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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 WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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?Antenna Manufacturer Coco
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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.pptxHampshireHUG
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Dernier (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

33443223 system-software-unit-iv

  • 1. QUESTION BANK UNIT IV CS 1203 SYSTEM SOFTWARE UNIT-III MACRO PROCESSORS MACRO PROCESSORS 9 Basic macro processor functions - Macro Definition and Expansion – Macro Processor Algorithm and data structures - Machine-independent macro processor features - Concatenation of Macro Parameters – Generation of Unique Labels – Conditional Macro Expansion – Keyword Macro Parameters-Macro within Macro-Implementation example - MASM Macro Processor – ANSI C Macro language. 1) Define Macro. A macro instruction (macro) is a notational convenience for the programmer. It allows the programmer to write a shorthand version of a program o A macro represents a commonly used group of statements in the source programming language. o Expanding the macros - the macro processor replaces each macro instruction with the corresponding group of source language statements. 2) What is a macro processor? A macro processor - Essentially involve the substitution of one group of characters or lines for another. Normally, it performs no analysis of the text it handles. It doesn’t concern the meaning of the involved statements during macro expansion o The design of a macro processor generally is machine independent. Three examples of actual macro processors: o A macro processor designed for use by assembler language programmers o Used with a high-level programming language o General-purpose macro processor, which is not tied to any particular language 3) What are the basic macro processor functions? Basic Macro Processors Functions Macro processor should processes the Macro definitions o Define macro name, group of instructions Macro invocation (macro calls) o A body is simply copied or substituted at the point of call Expansion with substitution of parameters o Arguments are textually substituted for the parameters
  • 2. o The resulting procedure body is textually substituted for the call 4) What are the Assembler directives used for Macro Definition? Macro Definition Two new assembler directives are used in macro definition: MACRO: identify the beginning of a macro definition MEND: identify the end of a macro definition o label op operands name MACRO parameters : body : MEND o Parameters: the entries in the operand field identify the parameters of the macro instruction We require each parameter begins with ‘&’ o Body: the statements that will be generated as the expansion of the macro. o Prototype for the macro: The macro name and parameters define a pattern or prototype for the macro instructions used by the programmer 5) Give an example program which uses Macro Definition. Macro Definition
  • 3. 6) How Macro is invoked in a program? Give example. Macro Invocation
  • 4. 7) What is Macro Expansion? Give an example. Macro Expansion Each macro invocation statement will be expanded into the statements that form the body of the macro. o Arguments from the macro invocation are substituted for the parameters in the macro prototype. The arguments and parameters are associated with one another according to their positions. o The first argument in the macro invocation corresponds to the first parameter in the macro prototype, etc. Macro Expansion Example Program From Fig. 4.1 with Macros Expanded (fig. 4.2)(Cont.) 8)Explain the functions of two pass macro processor.
  • 5. Two-pass macro processor o Two-pass macro processor o Pass1: process all macro definitions o Pass2: expand all macro invocation statements o Problem Does not allow nested macro definitions o Nested macro definitions o The body of a macro contains definitions of other macros Because all macros would have to be defined during the first pass before any macro invocations were expanded o Solution • One-pass macro processor 9) What is the characteristic of one pass macro processor? One-pass macro processor Every macro must be defined before it is called One-pass processor can alternate between macrodefinition and macro expansion Nested macro definitions are allowed 10) What are the data structures used by the macro processor? Data Structures o MACRO DEFINITION TABLE (DEFTAB) Macro prototype States that make up the macro body Reference to parameters are converted to a positional notation. o MACRO NAME TABLE (NAMTAB) Role: an index to DEFTAB Pointers to the beginning and end of the definition in DEFTAB o MACRO ARGUMENT TABLE (ARGTAB) Used during the expansion Invocation  Arguments are stored in ARGTAB according to their position
  • 6. 11) Write an algorithm for the Macro processor and explain. Algorithm and Data Structure (4)
  • 7. 12) What is the difference between a Macro and a subroutine? Differences between Macro and Subroutine After macro processing, the expanded file can be used as input to the assembler. The statements generated from the macro expansions will be assembled exactly as though they had been written directly by the programmer. The differences between macro invocation and subroutine call o The statements that form the body of the macro are generated each time a macro is expanded. o Statements in a subroutine appear only once, regardless of how many times the subroutine is called.
  • 8. 13) What are the machine independent features of macro processors? Other Macro Features Concatenation of macro parameters Generation of unique labels Conditional macro expansion Keyword Macro Parameters Concatenation of Macro Parameters Pre-concatenation o LDA X&ID1 Post-concatenation o LDA X&ID→1 Example: Figure 4.6 Concatenation Example Generation of Unique Labels Example o JEQ *-3 o inconvenient, error-prone, difficult to read Example Figure 4.7 $LOOP TD =X’&INDEV’ o 1st call: $AALOOP TD =X’F1’
  • 9. o 2nd call: $ABLOOP RDBUFF F1, BUFFER, LENGTH TD =X’F1’