z/OS MVS Programming: Extended Addressability Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Program return (PR) instruction

z/OS MVS Programming: Extended Addressability Guide
SA23-1394-00

The PR instruction performs several actions on the current entry in the linkage stack — the current entry being the entry formed by the most recent BAKR or stacking PC instruction:
  • If the current entry was added by a stacking PC or a BAKR instruction, the PR instruction returns control to the calling program.
  • The PR instruction restores the contents of the current entry, including the cross memory environment, the PSW, and the contents of registers 2 - 14.
  • The PR instruction removes the current linkage stack entry.

The PR instruction can execute in either primary or AR mode.

The following example shows the PR instruction and a use of the BAKR instruction.

CALLING PROGRAM SUBROUTINE
.
.
L    15,=A(SUBR)
BALR 14,15
.
.
.
.
     .
     .
     .
SUBR EQU *
     BAKR 14,0
     .
     .
     PR

In the example, the BALR branches to subroutine SUBR. When SUBR receives control, it uses BAKR to save the caller's status on the linkage stack. The BAKR saves the contents of register 14, which the calling program loaded with the address of the instruction after the BALR, on the linkage stack. Zero, as the second operand, means that the status information is saved and no branch occurs. The PR instruction in SUBR restores the caller's status, restores the contents of register 14, removes the current linkage stack entry, and returns to the instruction after the BALR in the calling program.

This use of the BAKR instruction is consistent with the MVS™ convention in which the called program saves the status of the caller. This convention is described in the section on linkage conventions in z/OS MVS Programming: Assembler Services Guide.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014