VMS Help  —  MACRO  /ALPHA  Directives  .MEXIT  Examples
      Example 1
      The following macro definition uses the .MEXIT directive
      to exit the current macro when it has finished processing a
      particular kind of argument:

                .macro STORE REG, LOCATION
                    .if identical,<REG>,<FP>
                        STQ REG, LOCATION
                        .mexit
                    .endc
                    .if identical,<REG>,<SP>
                        STQ REG, LOCATION
                        .mexit
                    .endc
                    .if identical,<%extract(0,1,<REG>)>,<R>
                        STQ REG, LOCATION
                        .mexit
                    .endc
                    .if identical,<%extract(0,1,<REG>)>,<F>
                        STT REG, LOCATION
                        .mexit
                    .endc
                    .error "Register argument is not a register"
                .endm STORE

      Example 2
      In this example, the STORE macro (as defined in Example 1)
      attempts to recognize its REG argument as either FP, SP, an
      integer register (a register with R as its first letter),
      or a floating-point register (a register with F as its first
      letter). The following example show two expansions of the STORE
      macro:

                STORE R1, 0(SP)
                    .if identical,<R1>,<FP>
                    .endc
                    .if identical,<R1>,<SP>
                    .endc
                    .if identical,<%extract(0,1,<R1>)>, <R>
                    .if identical,<R>,<R>
                        STQ R1, 0(SP)
                        .mexit

                STORE 24(SP), 16(SP)
                    .if identical,<24(SP)>,<FP>
                    .endc
                    .if identical,<24(SP)>,<SP>
                    .endc
                    .if identical,<%extract(0,1,<24(SP)>)>,<R>
                    .if identical,<2>,<R>
                    .endc
                    .if identical, <%extract(0,1<24(SP)>)>,<F>
                    .if identical,<2>,<F>
                    .endc
                    .error "Register argument is not a register"

      The first call of the STORE macro stores R1 at 0(SP). The
      STORE macro determines to do an integer store by recognizing
      the letter R as the first letter of the register name. After
      it has done so, it abandons further expansion of the macro
      using the .MEXIT directive. The second invocation attempts to
      store 24(SP) at 16(SP). Since the STORE macro cannot identify
      24(SP) as a legitimate register in any of the four forms it
      recognizes, the STORE macro does not attempt to store the
      REG argument, and does not abandon expansion with the .MEXIT
      directive. Instead, the STORE macro expands and issues a
      diagnostic message.
Close Help