Language Implementation
7-17
7
The 16 local registers (r0 through r15) are 32-bit registers that provide a
separate set of registers for each active function. Each time a function is
called, the processor automatically sets up a new set of local registers for
that function and saves the local registers for the calling function.
The particular use of each local register is:
•
r0 contains the previous frame pointer (pfp)
•
r1 contains the stack pointer (sp)
•
r2 contains the return instruction pointer (rip)
•
r3...r15 are general-purpose registers
Parameter Assignment to Registers
Parameters are passed in ascending-numbered registers, starting with g0,
in the order the parameters appear (left-to-right) in the actual call. Both
scalar and small aggregate (4 words or less) parameters are passed in
registers.
The size of a parameter's data type determines the number of registers the
parameter occupies. A parameter with a type size of one word or less
occupies one register. A parameter with a type size of two words or less
occupies two registers, and so on up to four words and four registers.
A parameter's type also determines in which register it must start. If the
type's alignment is 4 bytes or less then the parameter may be passed
starting in any register. If the type's alignment is 8 bytes then the
parameter must be passed starting in an even numbered register. If the
type's alignment is 16 bytes then the parameter must be passed starting in
g0, g4, or g8. Any gaps left in the parameter registers due to alignment
are not filled by following parameters.
Argument Blocks
An argument block is used to pass parameters when the parameters cannot
be passed in registers. This can occur either because there are not enough
registers left to pass the parameter, or when the parameter is too large
(greater than 4 words) to pass in registers. As soon as a parameter is
passed in an argument block, all further parameters get passed in the