Download presentation
Presentation is loading. Please wait.
Published byAlicia Swindlehurst Modified over 9 years ago
1
1 Macro Processors
2
2 Macro Processor l Recognize macro definitions l Save the macro definition l Recognize macro calls l Expand macro calls Source Code (with macro) Macro Processor Expanded Code Compiler or Assembler obj
3
3 Macro Definition l copy code l parameter substitution l macro instruction defining macros
4
4 Copy code -- Example Source STRG MACRO STADATA1 STBDATA2 STXDATA3 MEND. STRG. STRG. Expanded source. STADATA1 STBDATA2 STXDATA3. STADATA1 STBDATA2 STXDATA3. { {
5
5 Parameter Substitution -- Example Source STRG MACRO&a1, &a2, &a3 STA&a1 STB&a2 STX&a3 MEND. STRGDATA1, DATA2, DATA3. STRGDATA4, DATA5, DATA6. Expanded souce. STADATA1 STBDATA2 STXDATA3. STADATA4 STBDATA5 STXDATA6. { {
6
6 TEST START 2000h CELTOFERMACRO&CEL &FER LDA&CEL MULTNINE DIVFIVE ADDTHIRTYTWO STA&FER MEND CELTOFERCF CRESW1 FRESW1 NINEWORD9 FIVEWORD5 THIRYTWOWORD32 END Sample Code
7
7 One-Pass Macro Processor l Prerequisite »every macro must be defined before it is called l Sub-procedures »macro definition: DEFINE »macro invocation: EXPAND DEFINE EXPAND PROCESSLINE DEFTAB NAMTAB ARGTAB MACRO CALL
8
8 Data Structures -- Global Variables l DEFTAB l NAMTAB l ARGTAB EXPANDING
10
10
11
11
12
12 Nested Macros Definition l Macro definition within macros »process inner macro definition, during the expansion of outer macro Outer macro definition Inner macro definition
13
13 TEST START 2000h MACROSMACRO CELTOFERMACRO&CEL &FER LDA&CEL MULTNINE DIVFIVE ADDTHIRTYTWO STA&FER MEND MACROFMACRO CELTOFERMACRO&CEL &FER LDAF&CEL MULTFNINE DIVFFIVE ADDFTHIRTYTWO STAF&FER MEND Integer instructions set Floating point instructions set Nested Macro Definition Example
14
14 MACROS CELTOFERC F CRESW1 FRESW1 NINEWORD9 FIVEWORD5 THIRYTWOWORD32 MACROF CELTOFERC F CRESW1 FRESW1 NINEWORD9 FIVEWORD5 THIRYTWOWORD32 END Nested Macro Definition Example
15
15 One-Pass Macro Processor That Allows Nested Macro Definition l Sub-procedures »macro definition: DEFINE »macro invocation: EXPAND l EXPAND may invoke DEFINE when encounter macro definition DEFINE EXPAND PROCESSLINE DEFTAB NAMTAB ARGTAB Expanding MACRO CALL MACRO Definition
16
16 1-Pass Macro Processor
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.