When a primary mode program receives control, it can save the calling
program's registers on the linkage stack or in the caller-provided
save area. If using the caller-provided save area, then distinctions
are made as to whether the primary mode program is or is
not changing the 64–bit GPRs. Each possibility is discussed below.
Note that the linkage conventions assume that a primary mode program
does not use ARs. By leaving the contents of the ARs untouched, the
program preserves ARs 2-13 across program linkages.
A primary mode program that uses the linkage stack must:
- Issue a BAKR instruction which will save the caller's ARs and
64-bit GPRs on the linkage stack.
- Establish a GPR as a base register.
- Set GPR 13 to indicate that the caller's registers are saved on
the linkage stack:
- If the program creates a save area, obtain a 72-byte save area
on a word boundary (or 144-byte or larger on a doubleword boundary
if routines called by the program need that extra space) in the primary
address space:
- Set the second word of the save area to the character string 'F1SA'
if obtaining a 72-byte save area or 'F6SA' if obtaining a 144-byte
or larger save area
- Load GPR 13 with the save area address.
- If the program does not creates a save area, do one of following
actions:
- Load 0 into GPR 13.
- Set the second word of a two-word area in the primary address
space to the character string ‘F1SA’. Load the address of the two-word
area into GPR 13.
Conditions described for a primary mode program that uses the caller-provided
save area:
- Does not change 64–bit GPRs and that uses the 72–byte caller-provided
save area
- Changes 64-bit GPRs and that uses the 72-byte caller-provided
save area
- Changes 64-bit GPRs and that uses the 144-byte caller-provided
save area
Does not change 64–bit GPRs and that uses a 72–byte caller-provided
save area, the program must:
- Save 32-bit GPRs 0 - 12, 14, and 15 into the caller-provided save
area pointed to by GPR 13.
- Establish a base register.
- Obtain a 72-byte save area on a word boundary (or 144-byte or
larger on a doubleword boundary if routines called by the program
need that extra space) in the primary address space.
- Store the address of the caller's save area into the back chain
field of its own save area.
- Store the address of its save area into the forward chain field
of the caller's save area.
See Example.
Changes 64-bit GPRs and that uses the 72-byte caller-provided save
area, the program must:
Changes 64-bit GPRs and that uses the 144-byte caller-provided
save area, the program must:
- Save 64-bit GPRs 0 - 12, 14, and 15 into the caller-provided save
area pointed to by GPR 13 in F4SA format.
- Obtain a 144-byte save area on a doubleword boundary (or larger
if routines called by the program need that extra space) in the primary
address space.
- Store the address of the caller's save area into the back chain
field of its own save area.
- Store the address of its save area into the forward chain field
of the caller's save area.
- Set the word at offset 4 to "F4SA" to indicate how the caller's
registers were saved.
See Example.