VMS Help  —  MACRO  /ALPHA  Supplied Library Macros, Using the $CALL Macro, Using $CALL in Source Code
    This example uses the same source code from the previous example,
    except it uses the $CALL macro to show how to call a local and
    external routine.

    Example 4  Program Using $CALL

                .
                .
                .
            $CODE_SECTION             ; Switch to the code section
                                      ; ($CS points here)
                .
                .
                .
            MOV     R27,R2    1
            .base   R2, $LS   2
                .
                .
                .
            $CALL SUB1                ; Call external routine SUB1  3
            $CALL SUB2, LOCAL=TRUE    ; Call local routine SUB2     4
                .
                .
                .
            $RETURN                   ; Perform epilogue and return
            $END_ROUTINE MAIN         ; Mark the end of the routine

    1  The $LS symbol is defined to be the address of the procedure
       that is defined within the linkage section. The calling
       routine places the address of the procedure descriptor in
       R27 before making the call. This guarantees that the address
       associated with the symbol $LS is stored in R27 upon routine
       entry. Since the information in R27 is erased during a
       standard call, a copy is preserved in register R2.

    2  Register R2 now contains the address of our procedure
       descriptor, which is the base address of our linkage section.
       Since $LS is defined to point to the base address of the
       linkage section, the assembler computes the offsets within
       the linkage section using the .BASE directive.

    3  The $CALL macro calls the external routine SUB1.

    4  The $CALL macro calls the local routine SUB2. This call uses
       the LOCAL=TRUE keyword argument to indicate that routine SUB2
       is defined within the module.
Close Help