If starting in AMODE 64

An AMODE 64 program must specify SYSSTATE AMODE64=YES.

When it receives control, the target program saves the 64-bit GPRs into the 144-byte (or larger) doubleword-aligned caller-provided save area pointed to by 64-bit GPR 13. 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.

Figure 1. Format of the Format 4 Save Area (F4SA)
Word
Contents
0
Used by language products.
1
Value of "F4SA". "F4SA", stored by a program in its save area, indicates how the program has saved the calling program's registers, in this case saving the 64-bit GPRs 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).
You can save 64-bit GPRs either with a store-multiple (STMG) instruction or with the SAVE macro. Use the following STMG instruction to place the contents of all 64-bit GPRs except GPR 13 into the proper words of the save area:
STMG 14,12,8(13)
When SYSSTATE AMODE64=YES is in effect, the SAVE macro stores 64-bit GPRs into the save area. Code the GPRs to be saved in the same order as in a STMG instruction. The following example of the SAVE macro places the contents of all 64-bit GPRs except GPR 13 into the proper words of the save area.
 PROGNAME SAVE (14,12) 
Note: The SAVE macro will use STMG and store using the F4SA format when SYSSTATE AMODE64=YES is in effect, but will use STM and use the format mapped by the SAVER DSECT in macro IHASAVER when it is not. Thus a program that wants to use F4SA format but is not AMODE 64 should not use the SAVE macro.

Later, the program can use the RETURN macro (or the load-multiple (LMG) instruction) to restore 64-bit GPRs and return to the caller. Similar to the note for SAVE, a program that is using F4SA format but is not AMODE 64 should not use the RETURN macro.

Whether or not the target program creates its own save area, it must save the address of the calling program's save area. If the target program is creating a save area, it:
  1. Stores the 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.
  2. Stores the address of its own save area (the address the target program will place into 64-bit GPR 13) into words 34 and 35 of the calling program's save area.
  3. Saves the string "F4SA" into the 2nd word of its own save area. "F4SA" indicates how the target program has saved the calling program's registers, in this case saving the 64-bit GPRs 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 previous save areas should one be 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.

If you choose not to use the SAVE and RETURN macros, you can use the IHASAVER macro to map the fields in the save area.