Floating-Point Parameter Example

This example illustrates the rules for SH-4 argument passing.

Given the following declarations,

struct {
  float x;
  float y;
} point;

int myfunction(struct point p1, 
 float u, 
 struct point p2,
 double v, 
 float w, 
 float x, 
 double y, 
 double z);

The following table shows the arrangement of non-floating-point arguments in the registers and on the stack for the function myfunction.

Register Description
R4: p1.x, the first part of structure point 1
R5: p1.y, the second part of structure point 1
R6: Unused. This register would contain float u if using SH-3 calling convention or using varargs
R7: p2.x, the first part of structure point 2

Stack offset 16-19 contains p2.y, second part of structure point p2.

The following table shows the arrangement of floating-point arguments in the registers and on the stack for the function myfunction.

Register Description
FR4: Float u
FR5: Float w // w fills in the gap left by putting double v into DR6
DR6: Double v
FR8: Float x
FR9: Unused
DR10: Double y

Stack offset 44-51 contains double z.

See Also

SH-4 Parameter Passing | Argument Area | Argument Block | Argument Block Mapping | SH-4 Functions with Variable Argument Lists

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.