MIPS I, II Argument Registers
MIPS ISAs I and II run in 32-bit mode, and assign argument registers as follows, in precedence order:
- Double precision floating-point and 64-bit integer arguments to registers, beginning with even registers. This corresponds to always being 8-byte aligned when allocating memory on the stack for a 64-bit argument.
- Arguments prototyped with an ellipsis to corresponding general-purpose registers, if any corresponding general-purpose registers remain. For example, if the second argument prototype is an ellipsis, then if the first argument is four bytes, the allocation uses argument registers $5 through $7, beginning with the second argument, or, if the first argument was eight bytes, argument registers $6 through $7 beginning with the second argument.
- If the first argument is floating-point and floating-point hardware is present, a 4-byte float first argument uses float register $f12 and an 8-byte float first argument uses the float register pair starting at $f12.
- If the second argument is floating-point, floating-point hardware is present, and the first argument is floating-point, a 4-byte second argument uses float register $f14 and an 8-byte second argument uses the float register pair starting at $f14.
- If the second argument is an 8-byte float or integer, signed or unsigned, floating-point hardware is not present or the first argument is any integer data type, then the 8-byte second argument uses the general register pair starting at $6.
- Otherwise, allocation of argument registers is done using general registers $4 through $7.
The following list defines the use of the symbols in the table.
- d followed by a number represents a double precision, or 8-byte, floating-point argument.
- s followed by a number represents a single precision or 4-byte floating-point argument.
- n followed by a number represents a 4-byte non-floating-point argument
- J followed by a number represents an 8-byte non-floating-point argument, such as a _int64 argument.
Some entries have two register assignment sequences. The first represents the convention used with floating-point emulation; the second, if there is a difference, is the convention with floating-point hardware.
The following table shows how arguments are passed in registers.
Argument list | Register assignment |
---|---|
n1, n2, n3, n4 | n1> $4, n2 > $5, n3 > $6, n4 > $7 |
s1, s2, s3, s4 | s1 > $4, s2 > $5, s3 > $6, s4 > $7
s1 > $f12, s2 > $f14, s3 > $6, s4 > $7 |
d1, d2 | d1 > ($4, $5), d2 > ($6, $7)
d1 > $f12, d2 > $f14 |
s1, s2 | s1 > $4, s2 > $5
s1 > $f12, s2 > $f14 |
d1, s2 | d1 > ($4, $5), s2 > $6
d1 > $f12, s2 > $f14 |
s1, d2 | s1 > $4, d2 > ($6, $7)
s1 > $f12, d2 > $f14 |
s1, s2, d3 | s1 > $4, s2 > $5, d3 > ($6, $7)
s1 > $f12, s2 > $f14, d3 > ($6, $7) |
d1, s2, d3 | d1 > ($4, $5), s2 > $6, d3 > stack
d1 > $f12, s2 > $f14, d3 > stack |
d1, s2, s3, s4 | d1 > ($4, $5), s2 > $6, s3 > $7, s4 > stack
d1 > ($f12), s2 > $f14, s3 > $7, s4 > stack |
n1, d2 | n1 > $4, d2 > ($6, $7) |
n1, s1, d2 | n1 > $4, s1 > $5, d2 > ($6, $7) |
j1, d2 | j1 > ($4, $5), d2 > ($6, $7) |
j1, s2 | j1 > ($4, $5), s2 > $6 |
The following table illustrates what happens when an ellipsis appears in the second argument position. Notice that in all cases for all arguments matching the ellipsis and beyond only general purpose registers are used even if floating-point hardware is available.
Argument List | Register Assignment |
---|---|
n1, d2 | n1 > $4, d2 > ($6, $7) |
s1, d2 | s1 > $4, d2 > ($6, $7)
s1 > $f12, d2 > ($6, $7) |
d1, s2 | d1 > ($4, $5), s2 > $6
d1 > $f12, s2 > $6 |
d1, n1, d2 | d1 > ($4, $5), n1 > $6, d2 > stack
d1 > $f12, n1 > $6, d2 > stack |
j1, d2 | j1 > ($4, $5), d2 > ($6, $7) |
See Also
MIPS Stack Frame and Argument Registers | MIPS IV Argument Registers | MIPS Frame and Stack Pointers | MIPS Leaf Routines
Last updated on Thursday, April 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.