Macro Processor Macro Definition and call Macro Expansion
- Slides: 58
� Macro Processor: � Macro Definition and call, � Macro Expansion, � Nested Macro Calls and definition, � Advanced Macro Facilities, � Design of Macro Processor Sytem Programming
Introduction �A macro is a facility for extending a programming language. � A macro represents a commonly used group of statements in the source programming language � Each time this name Occurs in a program, the sequence of codes is substituted at that point. ◦ It allows the programmer to write shorthand version of a program. 2
Example | | | DATA DC 5 ADD 1, DATA ADD 2, DATA ADD 3, DATA | | | ADD 1, DATA ADD 2, DATA ADD 3, DATA | |
Macro � 3 main step of macro 1. Deifine the macro name 2. Write its definition 3. Use the macro name from with in the program anywhere its definition � Macro Definition ◦ Two new assembler directives �MACRO �MEND
Macro Instruction with parameter Syntax Start of definition……………. . MACRO Macro name with parameter……………… Sequence of instruction…………. . { End of definition………………. . . MEND Example: MACRO INCR &ARG ADD AREG, &ARG MEND 5
Types of Macro Expansion � 1. Lexical Expansion � 2. Semiantic Expansion 1. Lexical Expansion: Character string is replaced by another character string in the generation of program. All formal parameter is replaced by actual parameter. 2. Semiantic Expansion : Instruction as per requirement of specific usage are generated.
� MACRO: is the first line of the definition & identifies the following line as the macro instruction name. � The definition is terminated by with MEND statement � Macro call : macro processor replaces each macro call with macro instruction.
Example Source program | MACRO INCR ADD 1, DATA ADD 2, DATA ADD 3, DATA MEND | INCR | | | DATA DC 5 Expanded Source ADD 1, DATA ADD 2, DATA
Difference between macro and subroutine: � Difference between macro and subroutine: 1. a macro call is an instruction to replace the macro name with its body, whereas subroutine call is an instruction to transfer the program’s control to the subroutine’s definition with all paraneters, if required. 2. A macro call results in macro expansion, whereas subroutine call results in execution. 3. Macro expansion increases the size of the program but subroutine execution doesn’t affect the size of the program 4. Macro expansion doesn’t affect the execution speed of the program much in comparison to subroutines affect the execution speed of the program
3/3/2021 16
3/3/2021 17
3/3/2021 18
3/3/2021 19
3/3/2021 20
Example: MACRO INCR &X, &Y, ®=AREG MOVER ®, &X ADD ®, &Y MOVEM ®, &X MEND MACRO DECR &X, &Y, ®=BREG MOVER ®, &X SUB ®, &Y MOVEM ®, &X MEND
START 100 READ N 1 READ N 2 INCR N 1, N 2, REG=CREG DECR N 1, N 2 STOP N 1 DS N 2 DS END 1 1
3/3/2021 33
3/3/2021 34
3/3/2021 36
3/3/2021 37
Advanced Macro Facilities � Advanced Macro Facilities are basically used to enhance the semantic macro Expansion
� No operation is carried out by an ANOP instruction.
� No operation is carried out by an ANOP instruction.
� The length of A is 1.
� Used to create number of similar statement.
�Semantic � Semantic Expansion: expansion is the generation of instruction as per requirements of a specific usage
MACRO ). THRICE. ONCE . TWICE . THRICE . FINAL MEND VARY AIF AIF AGO MOVER ADD ADD AGO &COUNT , &ARG 1 (&COUNT. EQ. 1). ONCE (&COUNT. EQ. 2). TWICE (&COUNT. EQ. 3. FINAL AREG, X AREG, &ARG 1. FINAL MOVER AREG, X AREG, &ARG 1. FINAL
Expansion time Variable � These variables are declared as local variables: LCL <&var>[, <&var>……] EV can be manipulated using SET statement <EV> SET <Expr>
MACRO CLEAR MOVEM MOVEM MEND &ARG AREG=‘ 0’ AREG, &ARG+1 AREG, &ARG+2 AREG, &ARG+3
&M. MORE &M MACRO CLEAR &ARG, &N LCL &M SET 0 MOVER AREG, =‘ 0’ MOVEM AREG, &ARG+&M SET &M+1 AIF(&M. NE. &N). MORE MEND
MOVER MOVEM AREG, =‘ 0’ AREG, A……………. M=0 AREG, A+1 ………. . M=1 AREG, A+2 ………. . M=2 AREG, A+3 ………. . M=3
- Keyword macro parameters in system software
- In macro anop is used for
- One pass macro processor
- Macro processors are
- What is a macro processor
- Machine independent macro processor features
- Mercados macroeconomicos
- Characteristics of micro enterprise
- Conditional macro expansion
- Protective put payoff diagram
- Option terminology
- Gartner magic quadrant call recording
- Econmovies episode 5 worksheet answers
- Stimulus diffusion diagram
- Oblique shock relations
- Vliw processors rely on
- Comparison of 8086 and 8088
- Disadvantages of intel
- Dip and dunk tissue processor
- Westward expansion lewis and clark
- Thermal expansion and contraction examples
- Chapter 21 temperature heat and expansion
- Business expansion conglomerates and franchises
- Expansion exploration and encounters
- Unit 3 rev. statehood and westward expansion
- "atlantic crystals" miami or florida or construction
- Lesson 1 slavery and western expansion
- Nariman committee 1969
- Expansion and contraction weathering
- Chapter 11 growth and expansion
- Reduction translation technique examples
- Chapter 21 temperature, heat and expansion answer key
- Min term max term
- Guided reading activity 13-1 exploration and expansion
- Expansion and contraction
- Chapter 27 empire and expansion
- Chapter 10 expansion and conflict worksheet answers
- Solid liquid gas particles
- Chapter 12 territorial and economic expansion
- Business retention and expansion survey
- Copper thermal expansion coefficient
- Applications of boolean algebra
- Chapter 27 empire and expansion
- Territorial and economic expansion
- Chapter 21 temperature heat and expansion
- Chapter 21 temperature heat and expansion
- Chapter 11 growth and expansion vocabulary
- German and italian expansion
- Division reconciliation and expansion
- First call resolution measurement
- Call center one
- Call park definition
- What is php stands for
- Miles kimball food processor
- Processor expert
- Image picker
- Characteristics of multiprocessor
- Processor organization
- Minima processor