Macro Processor

A Macro instruction is the notational convenience for the programmer. For every occurrence of macro the whole macro body or macro block of statements gets expanded in the main source code. Thus Macro instructions makes writing code more convenient.

Silent features of Macro Processor:

  • Macro represents a group of commonly used statements in the source programming language.
  • Macro Processor replace each macro instruction with the corresponding group of source language statements. This is known as expansion of macros.
  • Using Macro instructions programmer can leave the mechanical details to be handled by the macro processor.
  • Macro Processor designs are not directly related to the computer architecture on which it runs.
  • Macro Processor involves definition, invocation and expansion.

Macro Definition and Expansion:




Line                 Label                 Opcode                 Operand
  
5                    COPY                  START                  0
10                   RDBUFF                MACRO                  &INDEV, &BUFADR
15                   
.
.
90
95                                         MEND

  • Line 10:
    RDBUFF (Read Buffer) in the Label part is the name of the Macro or definition of the Macro. &INDEV and &BUFADR are the parameters present in the Operand part. Each parameter begins with the character &.
  • Line 15 – Line 90:
    From Line 15 to Line 90 Macro Body is present. Macro directives are the statements that make up the body of the macro definition.
  • Line 95:
    MEND is the assembler directive that means the end of the macro definition.

Macro Invocation:


Line                 Label                 Opcode                 Operand
  
180                  FIRST                 STL                    RETADR
190                  CLOOP                 RDBUFF                 F1, BUFFER
15                   
.
.
255                                         END                    FIRST

Line 190:
RDBUFF is the Macro invocation or Macro Call that gives the name of the macro instruction being invoked and F1, BUFFER are the arguments to be used in expanding the macro. The statement that form the expansion of a macro are generated each time the macro is invoked.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.