SlideShare a Scribd company logo
MacroMacro
&&
Macro ProcessorsMacro Processors
INDEXINDEX
1.1. Macro expansionMacro expansion
2.2. Handling Nested Macro CallsHandling Nested Macro Calls
3.3. Design of Macro AssemblerDesign of Macro Assembler
Macro ExpansioNMacro ExpansioN
Macro ExpansioNMacro ExpansioN
Macro call leads to Macro Expansion.Macro call leads to Macro Expansion.
In Macro Expansion , Macro CallIn Macro Expansion , Macro Call
statement is replaced by astatement is replaced by a Sequence ofSequence of
Assembly statementsAssembly statements..
2 key notations used,,2 key notations used,,
Expansion time control flowExpansion time control flow
Lexical SubstitutionLexical Substitution
• AlgorithmAlgorithm::
– Initialize theInitialize the MEC (Macro Expansion counter)MEC (Macro Expansion counter)..
– Check the statement which is pointed by MEC isCheck the statement which is pointed by MEC is
notnot MENDMEND..
– If the statement is model statement.If the statement is model statement.
– Exit.Exit.
If( Statement = model Statement) thenIf( Statement = model Statement) then
Expand the statementExpand the statement
Increment MECIncrement MEC
ElseElse
MEC:=new value specified in statementMEC:=new value specified in statement
If( Statement = model Statement) thenIf( Statement = model Statement) then
Expand the statementExpand the statement
Increment MECIncrement MEC
ElseElse
MEC:=new value specified in statementMEC:=new value specified in statement
Macro ExpansioNMacro ExpansioN
• Tasks involvedTasks involved,,,,
– IdentifyIdentify Macro CallMacro Call
– Identify the Value OfIdentify the Value Of Formal ParameterFormal Parameter..
– MaintainMaintain Expansion time variablesExpansion time variables..
– OrganizeOrganize Expansion time control flowExpansion time control flow..
– Determining the values ofDetermining the values of sequencingsequencing
SymbolsSymbols..
– Expansion ofExpansion of model statementmodel statement..
Macro ExpansioNMacro ExpansioN
MACROMACRO
CLRMEMCLRMEM &P,&Q,&R1=AREG&P,&Q,&R1=AREG
LCCLCC &A&A
&A&A SETSET 00
MOVERMOVER &R1,=‘0’&R1,=‘0’
.MORE.MORE MOVEMMOVEM &R1,&P+&A&R1,&P+&A
&A&A SETSET &A+1&A+1
AIFAIF (&A NE Q).MORE(&A NE Q).MORE
MENDMEND
MACROMACRO
CLRMEMCLRMEM &P,&Q,&R1=AREG&P,&Q,&R1=AREG
LCCLCC &A&A
&A&A SETSET 00
MOVERMOVER &R1,=‘0’&R1,=‘0’
.MORE.MORE MOVEMMOVEM &R1,&P+&A&R1,&P+&A
&A&A SETSET &A+1&A+1
AIFAIF (&A NE Q).MORE(&A NE Q).MORE
MENDMEND
11 CLRMEMCLRMEM A,BA,BCLRMEMCLRMEM A,BA,B
22
33
44
55
66
Macro ExpansioNMacro ExpansioN
• Macro DefinitionMacro Definition  ParameterParameter
• Macro InvocationMacro Invocation  ArgumentArgument
• Body of Macro is Defined betweenBody of Macro is Defined between
MACROMACRO && MENDMEND directive statements.directive statements.
• After macro processing , the expandedAfter macro processing , the expanded
file can be used as I/P to thefile can be used as I/P to the
assembler.assembler.
Macro ExpansioNMacro ExpansioN
Lexical SubstitutioNLexical SubstitutioN
ConsistConsist 3 types3 types of string,,of string,,
11.Ordinary string..Ordinary string.
22.Name of Formal parameter preceded by.Name of Formal parameter preceded by
““&&”.”.
33.Name of Preprocessor Variables..Name of Preprocessor Variables.
Take stringTake string
as it is asas it is as
I/P.I/P.
Take stringTake string
as it is asas it is as
I/P.I/P.
TakeTake
ActualActual
parameterparameter
as I/P.as I/P.
TakeTake
ActualActual
parameterparameter
as I/P.as I/P.
TakeTake
ActualActual
parameterparameter
as I/P.as I/P.
TakeTake
ActualActual
parameterparameter
as I/P.as I/P.
Positional ParameterSPositional ParameterS
• Parameters & arguments associatedParameters & arguments associated
with each other according to theirwith each other according to their
PositioNPositioN in macro call & macroin macro call & macro
definition.definition.
• Syntax ,,Syntax ,,
• Ex,,Ex,, &&ROLLNOROLLNO
& < parameter name >& < parameter name >
MACROMACRO
INCRINCR &MEM_VAL,&INCR_VAL,&REG&MEM_VAL,&INCR_VAL,&REG
MOVERMOVER &REG,&MEM_VAL&REG,&MEM_VAL
ADDADD &REG,&INCR_VAL&REG,&INCR_VAL
MOVEMMOVEM &REG,&MEM_VAL&REG,&MEM_VAL
MENDMEND
MACROMACRO
INCRINCR &MEM_VAL,&INCR_VAL,&REG&MEM_VAL,&INCR_VAL,&REG
MOVERMOVER &REG,&MEM_VAL&REG,&MEM_VAL
ADDADD &REG,&INCR_VAL&REG,&INCR_VAL
MOVEMMOVEM &REG,&MEM_VAL&REG,&MEM_VAL
MENDMEND
INCR A,B,AREGINCR A,B,AREGINCR A,B,AREGINCR A,B,AREG
Formal ParameterFormal Parameter ValueValue
MEM_VALMEM_VAL AA
INCR_VALINCR_VAL BB
REGREG AREGAREG
Positional ParameterSPositional ParameterS
Keyword ParameterSKeyword ParameterS
• For keyword parameters,,For keyword parameters,,
<Parameter name><Parameter name> Ordinary stringOrdinary string
<Parameter kind><Parameter kind>  String “String “==””
<formal Parameter name><formal Parameter name>< Ordinary< Ordinary
string >string >
exex,,,, XYZ = ABCXYZ = ABC
SUMUPSUMUP X,Y,A=10,B=nX,Y,A=10,B=n Positional parameters:Positional parameters: X , YX , Y
Keyword parameters:Keyword parameters: A , BA , B
Positional parameters:Positional parameters: X , YX , Y
Keyword parameters:Keyword parameters: A , BA , B
Handling Nested MacroHandling Nested Macro
CallSCallS
Nested Macro CallSNested Macro CallS
• Nested macroNested macro  Macro may callMacro may call
another macro.another macro.
• Called macroCalled macro Inner macro.Inner macro.
MOVERMOVER BREG,TMPBREG,TMP
MOVERMOVER BREG,PBREG,P
ADDADD BREG,QBREG,Q
MOVEMMOVEM BREG,PBREG,P
MOVERMOVER BREG,TMPBREG,TMP
MOVERMOVER BREG,TMPBREG,TMP
MOVERMOVER BREG,PBREG,P
ADDADD BREG,QBREG,Q
MOVEMMOVEM BREG,PBREG,P
MOVERMOVER BREG,TMPBREG,TMP
MACROMACRO
COMPUTECOMPUTE &F,&S&F,&S
MOVERMOVER BREG,TMPBREG,TMP
INCR_DINCR_D &F,&S,REG=BREG&F,&S,REG=BREG
MOVERMOVER BREG,TMPBREG,TMP
MENDMEND
MACROMACRO
COMPUTECOMPUTE &F,&S&F,&S
MOVERMOVER BREG,TMPBREG,TMP
INCR_DINCR_D &F,&S,REG=BREG&F,&S,REG=BREG
MOVERMOVER BREG,TMPBREG,TMP
MENDMEND
Nested Macro CallSNested Macro CallS
MOVER BREG,TMPMOVER BREG,TMP
MOVERMOVER BREG,PBREG,P
COMPUTE P,QCOMPUTE P,Q INCR P,QINCR P,Q ADDADD BREG,QBREG,Q
MOVEMMOVEM BREG,PBREG,P
MOVERMOVER BREG,TMPBREG,TMP
MOVER BREG,TMPMOVER BREG,TMP
MOVERMOVER BREG,PBREG,P
COMPUTE P,QCOMPUTE P,Q INCR P,QINCR P,Q ADDADD BREG,QBREG,Q
MOVEMMOVEM BREG,PBREG,P
MOVERMOVER BREG,TMPBREG,TMP
Recursive MacroSRecursive MacroS
• Special caseSpecial case nested macros.nested macros.
• Recursive macroRecursive macro  MacroMacro expandsexpands
itself.itself.
• Not good but very useful.Not good but very useful.
• ProblemProblem: recursively expands so quickly: recursively expands so quickly
overflow theoverflow the MESMES..
• SolutionSolution: mechanism required to stop: mechanism required to stop
recursion.recursion. (conditional assembly(conditional assembly))
• Recursively generate INST1.Recursively generate INST1.
• No stop point.No stop point.
NOGOODNOGOOD MACROMACRO
INST1INST1
NOGOODNOGOOD
INST2INST2
ENDMENDM
Recursive MacroSRecursive MacroS
Design of Macro AssembleRDesign of Macro AssembleR
Design of Macro AssembleRDesign of Macro AssembleR
• 3 passes in macro Assembler.3 passes in macro Assembler.
Pass 1:Pass 1:
– Macro definition processing.Macro definition processing.
– SYMTAB construction.SYMTAB construction.
Pass 2Pass 2::
– Macro expansion.Macro expansion.
– Memory allocation & LC processing.Memory allocation & LC processing.
– Processing of Literals.Processing of Literals.
– Intermediate Code Generation.Intermediate Code Generation.
pass 3:pass 3:
– Target code Generation.Target code Generation.
– Macro processorMacro processor can be added as acan be added as a
processor to an assembler.processor to an assembler.
– It is implemented inIt is implemented in pass 1pass 1 of theof the
assembler.assembler.
Design of Macro AssembleRDesign of Macro AssembleR
Advantages:Advantages:
– Many functions don’t have to beMany functions don’t have to be
implemented twice.implemented twice.
– Less overheadLess overhead during processing. (byduring processing. (by
removing intermediate code)removing intermediate code)
– More flexibilityMore flexibility is available to theis available to the
programmer.programmer.
Design of Macro AssembleRDesign of Macro AssembleR
Disadvantages:Disadvantages:
• Combined pass 1 of the assembler &Combined pass 1 of the assembler &
macro processor may be toomacro processor may be too large for alarge for a
programprogram to fit into core of someto fit into core of some
machine.machine.
• ComplexityComplexity of such program may beof such program may be
overwhelming.overwhelming.
Design of Macro AssembleRDesign of Macro AssembleR
PASS 1PASS 1PASS 1PASS 1
RRRR
SearchSearch
pseudo-op Tablepseudo-op Table
SearchSearch
pseudo-op Tablepseudo-op Table
SearchSearch
Macro name TableMacro name Table
SearchSearch
Macro name TableMacro name Table
SearchSearch
machine-op Tablemachine-op Table
SearchSearch
machine-op Tablemachine-op Table
Go toGo to
PASS 2PASS 2
Go toGo to
PASS 2PASS 2Type?Type?Type?Type?
ProcessProcess
Macro definitionMacro definition
ProcessProcess
Macro definitionMacro definition
ProcessProcess
Pseudo-opsPseudo-ops
ProcessProcess
Pseudo-opsPseudo-ops
ProcessProcess
Machine instructionMachine instruction
ProcessProcess
Machine instructionMachine instruction
Setup macroSetup macro
stack frame ,etc.stack frame ,etc.
Setup macroSetup macro
stack frame ,etc.stack frame ,etc.
READREADREADREAD
RRRR
RRRR
RRRR
RRRR
Found, macroFound, macro
callscalls
FoundFound
NotNot
NotNot
EndEnd
pseudo-oppseudo-op
OthersOthers
MacroMacro
pseudo-oppseudo-op
@@
ThankThank
U!U!

More Related Content

What's hot

Life cycle of a computer program
Life cycle of a computer programLife cycle of a computer program
Life cycle of a computer programAbhay Kumar
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03desta_gebre
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1Manoj Patil
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit IIManoj Patil
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming ) Adarsh Patel
 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit ISaranya1702
 
memory reference instruction
memory reference instructionmemory reference instruction
memory reference instructionDeepikaT13
 
Register Reference Instructions | Computer Science
Register Reference Instructions | Computer ScienceRegister Reference Instructions | Computer Science
Register Reference Instructions | Computer ScienceTransweb Global Inc
 

What's hot (20)

Life cycle of a computer program
Life cycle of a computer programLife cycle of a computer program
Life cycle of a computer program
 
Pass 1 flowchart
Pass 1 flowchartPass 1 flowchart
Pass 1 flowchart
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Unit 4 sp macro
Unit 4 sp macroUnit 4 sp macro
Unit 4 sp macro
 
Loaders
LoadersLoaders
Loaders
 
Unit 2
Unit 2Unit 2
Unit 2
 
First pass of assembler
First pass of assemblerFirst pass of assembler
First pass of assembler
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
 
memory reference instruction
memory reference instructionmemory reference instruction
memory reference instruction
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
Macro Processor
Macro ProcessorMacro Processor
Macro Processor
 
Language processors
Language processorsLanguage processors
Language processors
 
Interrupts
InterruptsInterrupts
Interrupts
 
Register Reference Instructions | Computer Science
Register Reference Instructions | Computer ScienceRegister Reference Instructions | Computer Science
Register Reference Instructions | Computer Science
 
Assembler
AssemblerAssembler
Assembler
 

Viewers also liked

I-55 Q4 2016 Market Recap
I-55 Q4 2016 Market RecapI-55 Q4 2016 Market Recap
I-55 Q4 2016 Market RecapJonathan Lewis
 
Karma metal - beton kovasi kalibi tetrapod cnc plazma kesim boru bukme punch ...
Karma metal - beton kovasi kalibi tetrapod cnc plazma kesim boru bukme punch ...Karma metal - beton kovasi kalibi tetrapod cnc plazma kesim boru bukme punch ...
Karma metal - beton kovasi kalibi tetrapod cnc plazma kesim boru bukme punch ...Karma Metall
 
Macro features Film Studies
Macro features Film StudiesMacro features Film Studies
Macro features Film StudiesBen Atherton
 
Programmable Macro Language (Basic)
Programmable Macro Language (Basic)Programmable Macro Language (Basic)
Programmable Macro Language (Basic)Hadi Karimi
 
Assembler design option
Assembler design optionAssembler design option
Assembler design optionMohd Arif
 
Assembler design options
Assembler design optionsAssembler design options
Assembler design optionsMohd Arif
 
Interrupt of 8085
Interrupt of 8085Interrupt of 8085
Interrupt of 8085Nitin Ahire
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language ProcessingHemant Sharma
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programmingMukesh Tekwani
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit IIIManoj Patil
 
Instruction set of 8085 Microprocessor By Er. Swapnil Kaware
Instruction set of 8085 Microprocessor By Er. Swapnil KawareInstruction set of 8085 Microprocessor By Er. Swapnil Kaware
Instruction set of 8085 Microprocessor By Er. Swapnil KawareProf. Swapnil V. Kaware
 

Viewers also liked (20)

Ss4
Ss4Ss4
Ss4
 
I-55 Q4 2016 Market Recap
I-55 Q4 2016 Market RecapI-55 Q4 2016 Market Recap
I-55 Q4 2016 Market Recap
 
portfolio-dsamuels
portfolio-dsamuelsportfolio-dsamuels
portfolio-dsamuels
 
Karma metal - beton kovasi kalibi tetrapod cnc plazma kesim boru bukme punch ...
Karma metal - beton kovasi kalibi tetrapod cnc plazma kesim boru bukme punch ...Karma metal - beton kovasi kalibi tetrapod cnc plazma kesim boru bukme punch ...
Karma metal - beton kovasi kalibi tetrapod cnc plazma kesim boru bukme punch ...
 
Capitulo 1,2,3
Capitulo 1,2,3Capitulo 1,2,3
Capitulo 1,2,3
 
Al2ed chapter5
Al2ed chapter5Al2ed chapter5
Al2ed chapter5
 
Gelombang panas ppt
Gelombang panas pptGelombang panas ppt
Gelombang panas ppt
 
Coal 21- macro in Assembly Programming
Coal 21- macro in Assembly ProgrammingCoal 21- macro in Assembly Programming
Coal 21- macro in Assembly Programming
 
Macro features Film Studies
Macro features Film StudiesMacro features Film Studies
Macro features Film Studies
 
Programmable Macro Language (Basic)
Programmable Macro Language (Basic)Programmable Macro Language (Basic)
Programmable Macro Language (Basic)
 
Assembler design option
Assembler design optionAssembler design option
Assembler design option
 
Assembler design options
Assembler design optionsAssembler design options
Assembler design options
 
Interrupt of 8085
Interrupt of 8085Interrupt of 8085
Interrupt of 8085
 
Lease Operator
Lease OperatorLease Operator
Lease Operator
 
Fundamentals of Language Processing
Fundamentals of Language ProcessingFundamentals of Language Processing
Fundamentals of Language Processing
 
System programming
System programmingSystem programming
System programming
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
 
Macro
MacroMacro
Macro
 
Instruction set of 8085 Microprocessor By Er. Swapnil Kaware
Instruction set of 8085 Microprocessor By Er. Swapnil KawareInstruction set of 8085 Microprocessor By Er. Swapnil Kaware
Instruction set of 8085 Microprocessor By Er. Swapnil Kaware
 

Similar to Macros in system programing

Effectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMEffectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMNorberto Leite
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackKeitaSugiyama1
 
WCTF 2018 binja Editorial
WCTF 2018 binja EditorialWCTF 2018 binja Editorial
WCTF 2018 binja EditorialCharo_IT
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDinakar Guniguntala
 
Cp0675 03 may-2012-rm04
Cp0675 03 may-2012-rm04Cp0675 03 may-2012-rm04
Cp0675 03 may-2012-rm04Parth Mudgal
 
Kafka monitoring and metrics
Kafka monitoring and metricsKafka monitoring and metrics
Kafka monitoring and metricsTouraj Ebrahimi
 
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard WorldMonitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard WorldBrian Troutwine
 
Multi-Objective Evolutionary Algorithms
Multi-Objective Evolutionary AlgorithmsMulti-Objective Evolutionary Algorithms
Multi-Objective Evolutionary AlgorithmsSong Gao
 
Sonar rules in action with walkmod
Sonar rules in action with walkmodSonar rules in action with walkmod
Sonar rules in action with walkmodRaquel Pau
 
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...Cloud Native Day Tel Aviv
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaIsuru Perera
 

Similar to Macros in system programing (20)

Aocr Hmm Presentation
Aocr Hmm PresentationAocr Hmm Presentation
Aocr Hmm Presentation
 
handout6.pdf
handout6.pdfhandout6.pdf
handout6.pdf
 
Effectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMEffectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEM
 
Handout#05
Handout#05Handout#05
Handout#05
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM Stack
 
WCTF 2018 binja Editorial
WCTF 2018 binja EditorialWCTF 2018 binja Editorial
WCTF 2018 binja Editorial
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on Kubernetes
 
Cp0675 03 may-2012-rm04
Cp0675 03 may-2012-rm04Cp0675 03 may-2012-rm04
Cp0675 03 may-2012-rm04
 
Kafka monitoring and metrics
Kafka monitoring and metricsKafka monitoring and metrics
Kafka monitoring and metrics
 
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard WorldMonitoring Complex Systems: Keeping Your Head on Straight in a Hard World
Monitoring Complex Systems: Keeping Your Head on Straight in a Hard World
 
EVOLVE'15 | Enhance | Norberto Leite | Effectively Scale and Operate AEM with...
EVOLVE'15 | Enhance | Norberto Leite | Effectively Scale and Operate AEM with...EVOLVE'15 | Enhance | Norberto Leite | Effectively Scale and Operate AEM with...
EVOLVE'15 | Enhance | Norberto Leite | Effectively Scale and Operate AEM with...
 
Performance tests - it's a trap
Performance tests - it's a trapPerformance tests - it's a trap
Performance tests - it's a trap
 
Module 5.pdf
Module 5.pdfModule 5.pdf
Module 5.pdf
 
Multi-Objective Evolutionary Algorithms
Multi-Objective Evolutionary AlgorithmsMulti-Objective Evolutionary Algorithms
Multi-Objective Evolutionary Algorithms
 
Sonar rules in action with walkmod
Sonar rules in action with walkmodSonar rules in action with walkmod
Sonar rules in action with walkmod
 
Data day2017
Data day2017Data day2017
Data day2017
 
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
 
Performance
PerformancePerformance
Performance
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 

Recently uploaded

Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Krakówbim.edu.pl
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-IVigneshvaranMech
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdfAhmedHussein950959
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringC Sai Kiran
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsAtif Razi
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfAbrahamGadissa
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxMd. Shahidul Islam Prodhan
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringDr. Radhey Shyam
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdfKamal Acharya
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGKOUSTAV SARKAR
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edgePaco Orozco
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdfKamal Acharya
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectRased Khan
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industriesMuhammadTufail242431
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf884710SadaqatAli
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientistgettygaming1
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfKamal Acharya
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwoodseandesed
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopEmre Günaydın
 

Recently uploaded (20)

Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES  INTRODUCTION UNIT-IENERGY STORAGE DEVICES  INTRODUCTION UNIT-I
ENERGY STORAGE DEVICES INTRODUCTION UNIT-I
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 

Macros in system programing

  • 2. INDEXINDEX 1.1. Macro expansionMacro expansion 2.2. Handling Nested Macro CallsHandling Nested Macro Calls 3.3. Design of Macro AssemblerDesign of Macro Assembler
  • 4. Macro ExpansioNMacro ExpansioN Macro call leads to Macro Expansion.Macro call leads to Macro Expansion. In Macro Expansion , Macro CallIn Macro Expansion , Macro Call statement is replaced by astatement is replaced by a Sequence ofSequence of Assembly statementsAssembly statements.. 2 key notations used,,2 key notations used,, Expansion time control flowExpansion time control flow Lexical SubstitutionLexical Substitution
  • 5. • AlgorithmAlgorithm:: – Initialize theInitialize the MEC (Macro Expansion counter)MEC (Macro Expansion counter).. – Check the statement which is pointed by MEC isCheck the statement which is pointed by MEC is notnot MENDMEND.. – If the statement is model statement.If the statement is model statement. – Exit.Exit. If( Statement = model Statement) thenIf( Statement = model Statement) then Expand the statementExpand the statement Increment MECIncrement MEC ElseElse MEC:=new value specified in statementMEC:=new value specified in statement If( Statement = model Statement) thenIf( Statement = model Statement) then Expand the statementExpand the statement Increment MECIncrement MEC ElseElse MEC:=new value specified in statementMEC:=new value specified in statement Macro ExpansioNMacro ExpansioN
  • 6. • Tasks involvedTasks involved,,,, – IdentifyIdentify Macro CallMacro Call – Identify the Value OfIdentify the Value Of Formal ParameterFormal Parameter.. – MaintainMaintain Expansion time variablesExpansion time variables.. – OrganizeOrganize Expansion time control flowExpansion time control flow.. – Determining the values ofDetermining the values of sequencingsequencing SymbolsSymbols.. – Expansion ofExpansion of model statementmodel statement.. Macro ExpansioNMacro ExpansioN
  • 7. MACROMACRO CLRMEMCLRMEM &P,&Q,&R1=AREG&P,&Q,&R1=AREG LCCLCC &A&A &A&A SETSET 00 MOVERMOVER &R1,=‘0’&R1,=‘0’ .MORE.MORE MOVEMMOVEM &R1,&P+&A&R1,&P+&A &A&A SETSET &A+1&A+1 AIFAIF (&A NE Q).MORE(&A NE Q).MORE MENDMEND MACROMACRO CLRMEMCLRMEM &P,&Q,&R1=AREG&P,&Q,&R1=AREG LCCLCC &A&A &A&A SETSET 00 MOVERMOVER &R1,=‘0’&R1,=‘0’ .MORE.MORE MOVEMMOVEM &R1,&P+&A&R1,&P+&A &A&A SETSET &A+1&A+1 AIFAIF (&A NE Q).MORE(&A NE Q).MORE MENDMEND 11 CLRMEMCLRMEM A,BA,BCLRMEMCLRMEM A,BA,B 22 33 44 55 66 Macro ExpansioNMacro ExpansioN
  • 8. • Macro DefinitionMacro Definition  ParameterParameter • Macro InvocationMacro Invocation  ArgumentArgument • Body of Macro is Defined betweenBody of Macro is Defined between MACROMACRO && MENDMEND directive statements.directive statements. • After macro processing , the expandedAfter macro processing , the expanded file can be used as I/P to thefile can be used as I/P to the assembler.assembler. Macro ExpansioNMacro ExpansioN
  • 9. Lexical SubstitutioNLexical SubstitutioN ConsistConsist 3 types3 types of string,,of string,, 11.Ordinary string..Ordinary string. 22.Name of Formal parameter preceded by.Name of Formal parameter preceded by ““&&”.”. 33.Name of Preprocessor Variables..Name of Preprocessor Variables. Take stringTake string as it is asas it is as I/P.I/P. Take stringTake string as it is asas it is as I/P.I/P. TakeTake ActualActual parameterparameter as I/P.as I/P. TakeTake ActualActual parameterparameter as I/P.as I/P. TakeTake ActualActual parameterparameter as I/P.as I/P. TakeTake ActualActual parameterparameter as I/P.as I/P.
  • 10. Positional ParameterSPositional ParameterS • Parameters & arguments associatedParameters & arguments associated with each other according to theirwith each other according to their PositioNPositioN in macro call & macroin macro call & macro definition.definition. • Syntax ,,Syntax ,, • Ex,,Ex,, &&ROLLNOROLLNO & < parameter name >& < parameter name >
  • 11. MACROMACRO INCRINCR &MEM_VAL,&INCR_VAL,&REG&MEM_VAL,&INCR_VAL,&REG MOVERMOVER &REG,&MEM_VAL&REG,&MEM_VAL ADDADD &REG,&INCR_VAL&REG,&INCR_VAL MOVEMMOVEM &REG,&MEM_VAL&REG,&MEM_VAL MENDMEND MACROMACRO INCRINCR &MEM_VAL,&INCR_VAL,&REG&MEM_VAL,&INCR_VAL,&REG MOVERMOVER &REG,&MEM_VAL&REG,&MEM_VAL ADDADD &REG,&INCR_VAL&REG,&INCR_VAL MOVEMMOVEM &REG,&MEM_VAL&REG,&MEM_VAL MENDMEND INCR A,B,AREGINCR A,B,AREGINCR A,B,AREGINCR A,B,AREG Formal ParameterFormal Parameter ValueValue MEM_VALMEM_VAL AA INCR_VALINCR_VAL BB REGREG AREGAREG Positional ParameterSPositional ParameterS
  • 12. Keyword ParameterSKeyword ParameterS • For keyword parameters,,For keyword parameters,, <Parameter name><Parameter name> Ordinary stringOrdinary string <Parameter kind><Parameter kind>  String “String “==”” <formal Parameter name><formal Parameter name>< Ordinary< Ordinary string >string > exex,,,, XYZ = ABCXYZ = ABC SUMUPSUMUP X,Y,A=10,B=nX,Y,A=10,B=n Positional parameters:Positional parameters: X , YX , Y Keyword parameters:Keyword parameters: A , BA , B Positional parameters:Positional parameters: X , YX , Y Keyword parameters:Keyword parameters: A , BA , B
  • 13. Handling Nested MacroHandling Nested Macro CallSCallS
  • 14. Nested Macro CallSNested Macro CallS • Nested macroNested macro  Macro may callMacro may call another macro.another macro. • Called macroCalled macro Inner macro.Inner macro. MOVERMOVER BREG,TMPBREG,TMP MOVERMOVER BREG,PBREG,P ADDADD BREG,QBREG,Q MOVEMMOVEM BREG,PBREG,P MOVERMOVER BREG,TMPBREG,TMP MOVERMOVER BREG,TMPBREG,TMP MOVERMOVER BREG,PBREG,P ADDADD BREG,QBREG,Q MOVEMMOVEM BREG,PBREG,P MOVERMOVER BREG,TMPBREG,TMP MACROMACRO COMPUTECOMPUTE &F,&S&F,&S MOVERMOVER BREG,TMPBREG,TMP INCR_DINCR_D &F,&S,REG=BREG&F,&S,REG=BREG MOVERMOVER BREG,TMPBREG,TMP MENDMEND MACROMACRO COMPUTECOMPUTE &F,&S&F,&S MOVERMOVER BREG,TMPBREG,TMP INCR_DINCR_D &F,&S,REG=BREG&F,&S,REG=BREG MOVERMOVER BREG,TMPBREG,TMP MENDMEND
  • 15. Nested Macro CallSNested Macro CallS MOVER BREG,TMPMOVER BREG,TMP MOVERMOVER BREG,PBREG,P COMPUTE P,QCOMPUTE P,Q INCR P,QINCR P,Q ADDADD BREG,QBREG,Q MOVEMMOVEM BREG,PBREG,P MOVERMOVER BREG,TMPBREG,TMP MOVER BREG,TMPMOVER BREG,TMP MOVERMOVER BREG,PBREG,P COMPUTE P,QCOMPUTE P,Q INCR P,QINCR P,Q ADDADD BREG,QBREG,Q MOVEMMOVEM BREG,PBREG,P MOVERMOVER BREG,TMPBREG,TMP
  • 16. Recursive MacroSRecursive MacroS • Special caseSpecial case nested macros.nested macros. • Recursive macroRecursive macro  MacroMacro expandsexpands itself.itself. • Not good but very useful.Not good but very useful. • ProblemProblem: recursively expands so quickly: recursively expands so quickly overflow theoverflow the MESMES.. • SolutionSolution: mechanism required to stop: mechanism required to stop recursion.recursion. (conditional assembly(conditional assembly))
  • 17. • Recursively generate INST1.Recursively generate INST1. • No stop point.No stop point. NOGOODNOGOOD MACROMACRO INST1INST1 NOGOODNOGOOD INST2INST2 ENDMENDM Recursive MacroSRecursive MacroS
  • 18. Design of Macro AssembleRDesign of Macro AssembleR
  • 19. Design of Macro AssembleRDesign of Macro AssembleR • 3 passes in macro Assembler.3 passes in macro Assembler. Pass 1:Pass 1: – Macro definition processing.Macro definition processing. – SYMTAB construction.SYMTAB construction. Pass 2Pass 2:: – Macro expansion.Macro expansion. – Memory allocation & LC processing.Memory allocation & LC processing. – Processing of Literals.Processing of Literals. – Intermediate Code Generation.Intermediate Code Generation.
  • 20. pass 3:pass 3: – Target code Generation.Target code Generation. – Macro processorMacro processor can be added as acan be added as a processor to an assembler.processor to an assembler. – It is implemented inIt is implemented in pass 1pass 1 of theof the assembler.assembler. Design of Macro AssembleRDesign of Macro AssembleR
  • 21. Advantages:Advantages: – Many functions don’t have to beMany functions don’t have to be implemented twice.implemented twice. – Less overheadLess overhead during processing. (byduring processing. (by removing intermediate code)removing intermediate code) – More flexibilityMore flexibility is available to theis available to the programmer.programmer. Design of Macro AssembleRDesign of Macro AssembleR
  • 22. Disadvantages:Disadvantages: • Combined pass 1 of the assembler &Combined pass 1 of the assembler & macro processor may be toomacro processor may be too large for alarge for a programprogram to fit into core of someto fit into core of some machine.machine. • ComplexityComplexity of such program may beof such program may be overwhelming.overwhelming. Design of Macro AssembleRDesign of Macro AssembleR
  • 23. PASS 1PASS 1PASS 1PASS 1 RRRR SearchSearch pseudo-op Tablepseudo-op Table SearchSearch pseudo-op Tablepseudo-op Table SearchSearch Macro name TableMacro name Table SearchSearch Macro name TableMacro name Table SearchSearch machine-op Tablemachine-op Table SearchSearch machine-op Tablemachine-op Table Go toGo to PASS 2PASS 2 Go toGo to PASS 2PASS 2Type?Type?Type?Type? ProcessProcess Macro definitionMacro definition ProcessProcess Macro definitionMacro definition ProcessProcess Pseudo-opsPseudo-ops ProcessProcess Pseudo-opsPseudo-ops ProcessProcess Machine instructionMachine instruction ProcessProcess Machine instructionMachine instruction Setup macroSetup macro stack frame ,etc.stack frame ,etc. Setup macroSetup macro stack frame ,etc.stack frame ,etc. READREADREADREAD RRRR RRRR RRRR RRRR Found, macroFound, macro callscalls FoundFound NotNot NotNot EndEnd pseudo-oppseudo-op OthersOthers MacroMacro pseudo-oppseudo-op