Argument Block Mapping

Except for VarArgs functions and undeclared functions, functions map each of the first four integers or nonscalar words of the argument block to the general-purpose argument registers R4 through R7. General-purpose registers that are mapped to floating-point locations in the argument block remain unoccupied. If only part of a structure or union parameter fits into the first four words, the first part is passed in the general argument registers, and the rest of the structure or union is stored on the stack.

For the SH-4, functions may pass both single-precision and double-precision arguments in floating-point argument registers. Functions map single-precision floating-point arguments to FR registers, and double-precision floating-point arguments to DR registers. The mapping occurs in the order in which the arguments appear in the argument block.

Because the DR registers must have an even register-number alignment, gaps can be introduced in the sequence of registers. To utilize these gaps, functions map each floating-point argument to the lowest-numbered available register for that type. If the supply of double-precision registers is exhausted before the supply of single-precision registers, the double-precision arguments are assigned to argument-area memory locations on the stack and single-precision arguments continue to be assigned to single-precision floating-point registers until the supply of FR registers is also exhausted.

There is always a fixed mapping between a function's argument list and the corresponding argument block, but there is no fixed mapping between argument block offsets and the floating-point registers over all calls. Each call can have a different mapping. As a function encounters each floating-point argument in the list, it assigns the argument to the next available floating-point argument register, which depends on which registers have already been mapped.

Arguments not passed in any register are passed on the stack. These arguments are located in the argument area of the stack at the same offset as in the argument block.

For examples of single and float argument distribution, see Floating-Point Parameter Example.

See Also

SH-4 Parameter Passing | Argument Area | Argument Block | Floating-Point Parameter Example | SH-4 Functions with Variable Argument Lists

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.