VMS Help  —  MACRO  /ALPHA  Supplied Library Macros, Using Macros to Control Program Sections
    The following section explains how to use the MACRO-64 supplied
    macros to define and control the various program sections during
    assembly.

1  –  Defining Program Sections

    Each of the three program section types can be referenced by a
    corresponding macro. The following three macros are used to refer
    to and define these three psects associated within a routine:

    o  $CODE_SECTION-makes the routine's code psect current.

    o  $DATA_SECTION-makes the routine's data psect current.

    o  $LINKAGE_SECTION-makes the routine's linkage psect current.

    To switch to one of the current routine's sections, you invoke
    the corresponding macro. For example, after invoking $ROUTINE,
    to place instructions into the current routine's code psect,
    you invoke the $CODE_SECTION macro. This makes the code psect
    associated with the current routine the current psect. Similarly,
    invoking $LINKAGE_SECTION makes the linkage psect associated with
    the current routine the current psect.

    You can also control the psect name and attributes for each of
    the program sections by defining arguments to the $ROUTINE macro.

2  –  Using Macro Defined Symbols

    When you use any of the supplied macros described in this
    chapter, with the exception of $OPDEF, the following register
    symbols are defined for you:

       .DEFINE_IREG $IA0 R16 ; Integer argument 0
       .DEFINE_IREG $IA1 R17 ; Integer argument 1
       .DEFINE_IREG $IA2 R18 ; Integer argument 2
       .DEFINE_IREG $IA3 R19 ; Integer argument 3
       .DEFINE_IREG $IA4 R20 ; Integer argument 4
       .DEFINE_IREG $IA5 R21 ; Integer argument 5
       .DEFINE_FREG $FA0 F16 ; Floating-point argument 0
       .DEFINE_FREG $FA1 F17 ; Floating-point argument 1
       .DEFINE_FREG $FA2 F18 ; Floating-point argument 2
       .DEFINE_FREG $FA3 F19 ; Floating-point argument 3
       .DEFINE_FREG $FA4 F20 ; Floating-point argument 4
       .DEFINE_FREG $FA5 F21 ; Floating-point argument 5
       .DEFINE_IREG $AI R25 ; Argument-information register
       .DEFINE_IREG $RA R26 ; Return-address register
       .DEFINE_IREG $PV R27 ; Procedure-value register
       .DEFINE_IREG $FP R29 ; Frame pointer
       .DEFINE_IREG $SP R30 ; Stack pointer

                                   NOTE

       SP and FP remain predefined by MACRO-64 whether or not
       you use the OpenVMS Calling Standard macros. $SP and
       $FP are defined by the OpenVMS Calling Standard macros
       for consistency with the other register definitions that
       correspond to OpenVMS Calling Standard register conventions.

    The following symbols are defined by the $ROUTINE macro. These
    symbols are useful while programming with the calling-standard
    macros to refer to particular data and linkage section items.

    o  $CS-The address of the beginning of the current routine's code
       section.

    o  $LS-The address of the beginning of the current routine's
       linkage section.

    o  $DS-The address of the beginning of the current routine's data
       section.

    o  $DP-The linkage section address where the $ROUTINE macro
       places the .ADDRESS $DS to enable access to the data section
       from the linkage section (this variable is optional).

    o  $SIZE-The size of the fixed-stack area in bytes. $SIZE is
       defined using the value specified with the SIZE argument.

    o  $RSA_OFFSET-The offset within the fixed-stack area to the
       register save area. $RSA_OFFSET is defined using the value
       specified with the RSA_OFFSET argument.

    o  $RSA_END-The offset within the fixed-stack area to the first
       byte beyond the end of the register save area.

    For more information, see the description for the $ROUTINE macro
    in this chapter.

    The $CALL macro also defines the $STACK_ARG_SIZE symbol. This
    symbol specifies the number of bytes used to store arguments
    on the stack. This value is useful after calling a routine that
    returns a value on the stack. In this case, $CALL cannot remove
    the arguments from the stack because you must first retrieve the
    returned value from the stack. Subsequently, you can remove the
    arguments from the stack using the $STACK_ARG_SIZE symbol. For
    more information, see the description of $CALL in this chapter.

3  –  Defining Procedure Type

    The OpenVMS Calling Standard defines four types of routines;
    stack, register, null, and bound.

    You can define the routine type by using the KIND keyword
    argument with $ROUTINE or $PROCEDURE_DESCRIPTOR macros. The
    validity and values of other $ROUTINE and $PROCEDURE_DESCRIPTOR
    macro parameters are determined by the type of routine being
    declared. For example, a null procedure type has no stack size;
    therefore, the SIZE parameter is invalid and cannot be specified
    for a null procedure type. When using the KIND keyword with the
    $ROUTINE or $PROCEDURE_DESCRIPTOR macros, note the following
    exceptions:

    o  The $SIZE symbol defined by $ROUTINE is only valid for stack
       and register routines.

    o  The $RSA_OFFSET symbol defined by $ROUTINE is only valid for a
       stack routine.

4  –  Using Macros in Prologue Sections

    With stack and register routines, $ROUTINE generates a standard
    prologue sequence if you specify the STANDARD_PROLOGUE=TRUE
    keyword argument. STANDARD_PROLOGUE=TRUE is the default for
    register and stack routines.

    Alternatively, you can code your own prologue sequence by
    specifying the STANDARD_PROLOGUE argument as FALSE and using the
    $END_PROLOGUE macro to mark the end of your prologue sequence. In
    this case, you may wish to use the $SIZE and $RSA_OFFSET symbols
    to symbolically specify the fixed-stack size and register save
    area offset, respectively.

    For more information on the prologue sequence of instructions
    that must occur at the beginning of all stack and register
    routines, see the OpenVMS Calling Standard.

5  –  Using Macros in Epilogue Sections

    With stack and register routines, you can use the $RETURN
    macro to generate an epilogue sequence. Alternatively, you
    can code your own epilogue sequence using the $BEGIN_EPILOGUE
    and $END_EPILOGUE macros to mark the beginning and end of your
    epilogue sequences.

    The OpenVMS Calling Standard also describes the epilogue sequence
    of instructions that must be executed every time a stack or
    register routine returns to its caller.
Close Help