Page 107 - DCAP507_SYSTEM_SOFTWARE
P. 107

Unit 7: Macro Language




              The macroprocessor removes all incidences of the concatenation operator  immediately  Notes
               after carrying out parameter substitution, so the character 'will not appear in the macro
               expansion.

          7.2.2 Generation of Unique Labels

              Labels in the macro body may reason "duplicate labels" problem if the macro is invocated
               and expanded multiple times.

              Utilization of relative addressing at the source statement level is very inconvenient, error-
               prone, and hard to read.
              It is extremely attractive to let the programmer use label in the macro body.

              Labels utilized within the macro body start with $.2. Let the macro processor produce
               unique labels for every macro invocation and expansion.
              Throughout macro expansion, the $ will be substituted with $xx,  where xx  is a  two-
               character alphanumeric counter of the number of macroinstructions extended.
              XX=AA, AB, AC …….
               Consider the definition of WRBUFF
                    COPY             START             0



                    TD                                 =X'&OUTDEV'



                    JEQ                                *-3


                    JLT                                *-14


                    END                                FIRST

              If a label was positioned on the TD instruction on line 135, this label would be defined
               twice, once for every invocation of WRBUFF.

              This duplicate definition would avert correct assembly of the resulting expanded program.
              The jump instructions on line 140 and 155 are written by means of the relative operands *-
               3 and *-14, since it is not possible to position a label on line 135 of the macro definition.

              This relative addressing may be suitable for short jumps like " JEQ *-3"
              For longer jumps spanning several instructions, such notation is very inopportune, error-
               prone and difficult to read.

              Many microprocessors avoid these problems by permitting the creation of special types
               of labels inside macro instructions.












                                           LOVELY PROFESSIONAL UNIVERSITY                                   101
   102   103   104   105   106   107   108   109   110   111   112