The notion of whether some of these linkage instructions could be
thought of as "save" and "then branch" is interesting and hasn't
changed since the introduction of the S/360.

The fundamental concept is that as a part of normal instruction
sequencing, the addressing information found in the PSW is updated
as part of the instruction fetch and decode process (the instruction
length code is used to adjust the instruction address portion of the
PSW).  For the RR format of these instructions when the "R2" operand
is non-zero, the information contained in the "R2" operand is used
to compute updated addressing information to be placed into the PSW.
The addressing information currently contained in the PSW (this is
the "link" information) is placed into the GPR designated by the
"R1" operand prior to conditionally (when the "R2" operand is
non-zero) replacing the addressing information in the PSW with the
computed addressing information (this is the "branch" information).
At the completion of the instruction the newly formed PSW is used.

Specifying the same non-zero values for the "R1" and "R2" operands
on BALR or BASR takes advantage of this concept.  I have seen
linkage assist services which work in this manner (frequently with
the aid of a macro):

- GPR 15 is loaded with the address of a function to be called.

- GPR 14 is loaded with the address of the linkage assist service.

- The linkage assist service is invoked via BASR R14,R14.

- The linkage assist service deals with maintaining a "stack" of
  Save Areas (used to save/restore caller registers and other useful
  information), loads GPR 14 with the address of the service which
  unwinds the stack (to effect the "return" to the original caller),
  and transfers control to the target function whose address was
  contained in GPR 15 at entry to the linkage assist service.

- Upon its completion, the called function "returns" to the address
  contained in GPR 14 at its entry (which transfers control to the
  stack unwinding service which, in turn, ultimately transfers
  control to the original caller).

I have no idea if CICS does this kind of stuff.

Quoting from the description of the BAL and BALR instructions as
found in the September 1968 edition of the S/360 Principles of
Operation:

"The branch address is determined before the link information is
stored."

The z/Architecture Principles of Operation essentially states the
same thing about BAL, BALR, BAS, BASR:

"The branch address is computed before general register R1 is
changed."

And this is in the description of BASSM:

"The new value for the PSW is computed before general register R1 is
changed."

Reply via email to