Integer and Non-scalar Parameters
In most circumstances, the first four 32-bit words of integer or nonscalar arguments are passed in registers R4-R7. The remaining words are placed on the stack frame, starting at a displacement of 16 bytes from the stack pointer. Parameter passing is based on the SH-3 calling sequence specification. For more information about calling sequence specifications, see SH-3 Calling Sequence Specification, SH3-DSP Calling Sequence Specifications, and SH-4 Calling Sequence Specification. For a complete description of the SH-3 or SH-4 calling standard, see the Hitachi SH-3 Calling Standard or the Hitachi SH-4 Calling Standard.
The following example shows how to access parameters from registers and local argument stack space according to the calling standards.
__asm(
"add R4,R5 ; add first two numbers\n"
"add R5,R6 ; add third number\n"
"add R6,R7 ; add fourth number\n"
"mov.l @(16,SP), R0 ; retrieve fifth number\n"
"add R0,R7 ; add fifth number\n"
"mov.l @(20,SP), R0 ; get address of result\n"
"mov.l R7,@R0 ; save results"
,num1 // passed in R4
,num2 // passed in R5
,num3 // passed in R6
,1000 // passed in R7
,0xFFFF // passed in stack at a displacement of 16 bytes from SP
,&result // passed in stack at a displacement of 20 bytes from SP
);
For the preceding example, the compiler places num1 in R4, num2 in R5, num3 in R6, and 1000 in R7. The remaining arguments 0xffff and &result will be placed in the stack frame.
See Also
SH-3 Calling Sequence Specification | SH3-DSP Calling Sequence Specifications | SH-4 Calling Sequence Specification | SHx Inline Assembly Parameters | Floating-point and Double Parameters
Last updated on Thursday, April 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.