If changing ARs without using the linkage stack
An AR mode program must specify SYSSTATE ASCENV=AR.
When a program that changes ARs and chooses not to use the linkage stack receives control, the target program saves the GPRs and ARs into the 216-byte (or larger) doubleword-aligned caller-provided save area pointed to by GPR 13 (and AR 13 when the caller is in AR mode). The format of this area is shown in Figure 1. As indicated by this figure, the contents of each GPR, except GPR 13, must be saved in a specific location within the save area. GPR 13 is not saved into the save area; it holds the address of the save area. Similarly, the contents of each AR, except AR 13, must be saved in a specific location within the save area. AR 13 is not saved into the save area; it holds the ALET of the save area.
- Word
- Contents
- 0
- Used by language products.
- 1
- Value of
F7SA
.F7SA
, stored by a program in its save area, indicates how the program saves the calling program's registers. Saving the 64-bit GPRs and the ARs in the caller-provided save area whose address is in words 32-33 of this save area. - 2 - 3
- 64-bit GPR 14 (return address).
- 4 - 5
- 64-bit GPR 15.
- 6 - 31
- 64-bit GPRs 0 - 12.
- 32 - 33
- Address of previous save area (stored by a program in its save area).
- 34 - 35
- Address of next save area (stored by target program within caller's save area).
- 36 - 50
- ARs 14, 15, 0-12.
- 51
- ALET of previous save area.
- 52
- ASC mode of calling program.
- 53
- Undefined.
STMG 14,12,8(13)STAM 14,12,144(13)Later, the program can use the LAM and LMG instructions to restore ARs and GPRs and return to the caller.
- Stores the 64-bit address of the calling program's save area (the address passed in 64-bit GPR 13) into words 32 and 33 of its own save area.
- Stores the ASC mode of the calling program into word 52 of its own save area.
- Stores the ALET of the calling program's save area (the value in AR 13) into word 51 of its own save area
- Stores the address of its own save area (the address the target program places in GPR 13) into words 34 and 35 of the calling program's save area.
- Saves the string
F7SA
into the second word of its own save area.F7SA
indicates how the target program saves the calling program's registers. Saving the 64-bit GPRs and the ARs in the caller-provided save area whose address is in words 32-33 of this save area.
These steps enable the target program to find the calling program's save area when it needs it to restore the caller's registers, and they enable a trace backward from the most recent save area to a previous save area if one is necessary while examining a dump. If the target program is not creating a save area, it can keep the address of the calling program's save area in GPR 13 or store it in a location in virtual storage.
Use the IHASAVER macro to map the fields in the save area.
If your program is AR mode but the calling program is not known to be AR mode (it might be known to be primary ASC mode or it might be either primary ASC or AR mode), you need to save the calling program's mode on entry and restore it on exit.