Standard Linkage

In the following linkage routine, R13 serves as both the save area pointer and the base register.  Note the technique of pairing labels in absolute expressions giving a displacement from the load address.

SGLINK   CSECT
         B     AROUND-SGLINK(,R15)      SKIP PROGRAM ID
         DC    CL8'SGLINK',CL1'-',CL8'&SYSDATE',CL1'-',CL8'&SYSTIME'
AROUND   DS    0H
         STM   R14,R12,12(R13)          SAVE CALLER'S REGS
         CNOP  0,4                      ALIGN BAS TO SAVEAREA
         BAS   R12,NEXT-SGLINK(,R15)    R12 = TEMP SAVEAREA PTR
SAVEAREA DC    18F'0'
NEXT     ST    R12,8(,R13)              LOAD CALLER'S FORWARD PTR
         ST    R13,4(,R12)              LOAD MY BACKWARD PTR
         LR    R13,R12                  R13 = SAVEAREA PTR
         USING SAVEAREA,R13               AND BASE REG
*
         L     R13,4(,R13)              RESTORE CALLER'S REGS
         LM    R14,R12,12(R13)
         XR    R15,R15                  SET RC=0
         BR    R14
*

Copyright © 2006 The Stevens Computing Services Company, Inc.  All rights reserved.