[fpc-devel] Re. z370 Cross Compilation, Pass 2 of ....
bernd.oppolzer at t-online.de
Mon Sep 2 00:43:10 CEST 2013
Am 01.09.2013 21:42, schrieb Mark Morgan Lloyd:
> No, I meant that Bernd suggested R1 earlier as a simulated stack
> pointer. Does IBM use R1 for this on variants of the architecture that
> have push/pop opcodes, or some other general-purpose register, or a
> dedicated register?
R1 was only meant as an example.
The true linkage and stack conventions of (most) IBM OSes are like this:
R13 points to the save areas of the current procedure or function (that is
the current stack frame of this procedure; at the beginning of this
there is always a register save area for the 16 general purpose registers,
which contain the return adress, entry point and parameter base adress,
Following this save area, we have the local (automatic) variables of the
current procedure or function. If a parameter list for the call of a
procedure has to be built, this is also done in a work area which is
the stack frame of this function, and before calling the next function,
R1 is set to point to the beginning of this area.
R15 always contains the entry point address for the new procedure,
and R14 always contains the return address. All 16 registers are saved
in the prologue of the new procedure and restored upon return - with the
exception of R13 itself, which is handled separately - the save areas
are chained together using the 2nd and 3rd word (backward and
foreward pointer). This is the way how the contents of R13 are saved.
The are machine instructions to do the register saves and restores in
a convenient way - all the registers from R0 to R15 (with the exception
of R13) are saved and restored using one machine instruction.
It looks like this:
STM R14,R12,12(R13) - that is, R14,R15, and R0 thru R12 are saved
at offset 12 from R13.
More information about the fpc-devel