21.2 Mainframe registers

If you develop your own applications, it may be of use to know something about the mainframe register sets. A full description is in S/390 ELF Application Binary Interface Supplement and zSeries ELF Application Binary Interface Supplement, both available at http://www.linuxbase.org/spec/ELF/zSeries/.

21.2.1 zSeries registers

S/390 has 16 general-purpose registers of 32-bit width; with zSeries, the registers are 64-bit wide. The number of floating-point registers depends on the model. Older systems have only four floating-point registers; recent systems come with 16. The 16 registers were introduced together with the IEEE floating-point implementation. All Linux programs are able to use 16 floating-point registers. The missing 12 on older hardware are emulated within the Linux kernel. The use of the registers on z/Architecture is described in Table 21-2.

Table 21-2. Register usage

Register name

Usage

Call effect

r0, r1

General purpose

Volatile[1]

r2

Parameter passing and return values

Volatile

r3, r4, r5

Parameter passing

Volatile

r6

Parameter passing

Saved[2]

r7 r11

Local variables

Saved

r12

Local variable, commonly used as GOT pointer

Saved

r13

Local variable, commonly used as literal pool pointer

Saved

r14

Return address

Volatile

r15

Stack pointer

Saved

f0, f2, f4, f6

Parameter passing and return values

Volatile

f1, f3, f5, f7

General purpose

Volatile

f8 f15

General purpose

Saved

Access registers 0, 1

Reserved for system use

Volatile

Access registers 2 15

General purpose

Volatile

[1] Volatile: These registers are not preserved across function calls.

[2] Saved: These registers belong to the calling function. A called function will save these registers' values before it changes them, restoring their values before it returns.

The registers in Table 21-3 have assigned roles in the standard calling sequence.

Table 21-3. Standard calling sequence roles

r12

Global Offset Table pointer. If a position-independent module uses cross-linking, the compiler must point r12 to the GOT. If not, this register may be used locally.

r13

Commonly used as the literal pool pointer. If the literal pool is not required, this register may be used locally.

r14

This register will contain the address to which a called function will normally return. r14 is volatile across function calls.

r15

The stack pointer (stored in r15) will maintain an 8-byte alignment. It will always point to the lowest allocated valid stack frame and will grow toward low addresses. The contents of the word addressed by this register may point to the previously allocated stack frame. If required, it can be decremented by the called function.

Signals can interrupt processes. Functions called during signal handling have no unusual restrictions on their use of registers. Moreover, if a signal-handling function returns, the process will resume its original execution path with all registers restored to their original values. Thus programs and compilers may freely use all registers listed above, except those reserved for system use, without the danger of signal handlers' inadvertently changing their values.

Register usage

With these calling conventions, the following usage of the registers for inline assemblies is recommended:

  • General registers r0 and r1 should be used internally whenever possible.

  • General registers r2 to r5 should be second choice.

  • General registers r12 to r15 should be used only for their standard function.



Linux on the Mainframe
Linux on the Mainframe
ISBN: 0131014153
EAN: 2147483647
Year: 2005
Pages: 199

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net