[fpc-devel] Re. z370 Cross Compilation, Pass 2 of ....

Mark Morgan Lloyd markMLl.fpc-devel at telemetry.co.uk
Mon Sep 2 10:37:22 CEST 2013

Bernd Oppolzer wrote:
> 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 
> stack frame
> there is always a register save area for the 16 general purpose registers,
> which contain the return adress, entry point and parameter base adress, 
> too).
> 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 
> subsequent
> procedure has to be built, this is also done in a work area which is 
> part of
> 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.

That's obviously far friendlier to a language like Pascal than the 
examples in most assembler-level treatises- I wonder how compatible it 
is with the description of the Linux ABI informally at 
http://linuxvm.org/present/SHARE99/S8139db.pdf ?

I notice that Paul has added updates to 
http://wiki.lazarus.freepascal.org/ZSeries over the last week or so but 
haven't had time to read them in detail yet.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-devel mailing list