Examples Program Using Supplied Macros and Program Using $CALL show how to use the calling-standard macros to define a routine, switch control between psects, generate an epilogue sequence, and end the routine. Example 3 Program Using Supplied Macros $ROUTINE MAIN, KIND=STACK, - ; Stack routine kind 1 SAVED_REGS=<FP>, - ; Saves FP 2 SIZE=48 ; Stack size is 48 3 $LINKAGE_SECTION ; Switch to the linkage psect. 4 X: .long 6 ; X is a constant FP1_ADDR: ; FP1_ADDR -> FP1 .address FP1 $DATA_SECTION ; Switch to the data section 5 A:: .blkw 5 ; $DS points here B:: .blkw $CODE_SECTION ; Switch to the code section 6 ; ($CS points here) . . . $RETURN ; Perform epilogue and return 7 $END_ROUTINE MAIN ; Mark the end of the routine 8 1 $ROUTINE defines the routine MAIN. The routine type is defined as a stack routine using the KIND=STACK keyword argument. 2 The keyword argument SAVED_REGS=<FP> adds the frame pointer register to the list of registers saved on the stack by the prologue code. The SAVED_REGS keyword is valid only for stack procedures. If you do not specify the FP register (R29) with this argument, it is assumed. 3 The keyword argument SIZE=48 defines the stack area in bytes. This argument is valid only for register and stack routines. If you do not specify a stack size for a stack or register routine, $ROUTINE computes the minimum stack size required to accommodate the other arguments you specify or leave as the default. 4 The $LINKAGE_SECTION macro switches to the linkage section. You can use the $LS symbol created by the $ROUTINE macro to point to the address of the current routine's linkage section. $ROUTINE creates the procedure descriptor and leaves the current location counter within the linkage section just beyond the procedure descriptor. 5 The $DATA_SECTION macro switches to the data section. You can use the $DS symbol created by the $ROUTINE macro to point to the address of the current routine's data section. 6 The $CODE_SECTION macro switches to the code section. The $CS symbol created by the $ROUTINE macro is used to point to the address of the current routine's code section. 7 The $RETURN macro generates a standard epilogue instruction sequence. You can use this macro only with stack or register routine defined with the $ROUTINE macro. 8 The $END_ROUTINE macro marks the end of the routine.