Page 97 - DCAP507_SYSTEM_SOFTWARE
P. 97

Unit 7: Macro Language




          7.1 Macro Instructions                                                                Notes

          A macro instruction (macro) is just a notational expediency for  the programmer to write a
          shorthand edition of a program. It symbolizes a usually used group of statements in the source
          program. It is substituted by the macro processor with the equivalent group of source language
          statements.



             Did u know?  The above explained operation is known as "expanding the macro".


                 Example: Suppose it is essential to save the contents of all registers before calling a
          subroutine. This needs a series of instructions. We can define and utilize a macro, SAVEREGS, to
          signify this sequence of instructions.

          7.1.1 Macro Processor

          A macro processor functions fundamentally engross the replacement of one group of characters
          or lines for another. Usually, it performs no analysis of the text it manages. It doesn't regard the
          meaning of the involved statements throughout macro expansion. Thus, the design of a macro
          processor usually is machine independent.




             Notes   Macro  processors  are  used  in assembly  language, high-level  programming
             languages, e.g., C or C++, OS command languages, and universal purpose.


          7.1.2 Format of Macro Definition

          A macro can be defined as follows MACRO - MACRO pseudo-op displays beginning of macro
          definition. Name [List of Parameters] - Macro name with a list of formal parameters.
          …….
          ……
          .…….           Sequence of assembly language instructions.
          MEND- MEND (MACRO-END) Pseudo displays the end of macro definition.


                 Example:

          MACRO
                 SUM X,Y
                 LDA X
                 MOV BX,X

                 LDA Y
                 ADD BX
                 MEND






                                           LOVELY PROFESSIONAL UNIVERSITY                                   91
   92   93   94   95   96   97   98   99   100   101   102