Share via


ARM Parameter Passing

In general, the argument list resembles a memory-based structure with padding inserted to achieve appropriate alignment.

The following list shows the parameter passing conventions:

  • A calling function passes the first four 32-bit words in registers R0 through R3.

    If a called function takes the address of an argument passed in these registers, and if the resulting pointer might be used to reference subsequent arguments, the calling function must copy that argument and all that follow it in the registers to the stack area reserved for that purpose. To facilitate the use of varargs techniques, the reserved area is adjacent to the rest of the argument list.

  • If integer and integer-equivalent arguments such as char or pointer are not larger than 32-bits, a calling function passes them as 32-bit words. If the argument is 64-bits, the function passes it as a 4-byte aligned scalar.

  • A calling function passes 64-bit floating-point arguments of type double as 4-byte aligned scalars, and passed 32-bit floating-point arguments of type float as 32-bit words.

  • It passes a structure or union parameter as a copy. The function then passes the first four words of the resulting memory image in integer registers, and places the remaining words of the argument list image on the stack. If a structure or union parameter is too large to fit completely in the first four words of the argument list, the remainder is stored on the stack.

The ARM/THUMB calling sequence provides a varargs implementation to enable a variable argument list.

The following list shows the ARM varargs implementation:

  • A routine can implement va_list as a C pointer.
  • A routine can implement va_arg() to properly cast and de-reference the va_list. It can then increment the va_list by the size of the given type.
  • A routine can implement va_start() to return the address of the item immediately following the start address.
  • A routine can implement va_end() as a no operation instruction (NOP).

See Also

ARM Calling Sequence Specification | What's New for the ARM Compiler | ARM Registers | ARM Stack Frame Layout | ARM Return Values | ARM Prolog and Epilog | ARM pdata Structures | ARM Assembler Macros

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.