0

I would like an example of the convention used when writing an assembly subroutine called from C.There are no resources online that explain where arguments that are integer and floating point type are stored. I have floating point hardware on the ARM and am able to pass in floating point numbers into floating point registers. But how do I pass in integers into integer registers and floating point values into floating point registers at the same time.

  • 2
    Examine the code that your ARM compiler generates for simple C functions? – sigjuice Mar 16 '17 at 01:11
  • 2
    The calling convention is fully documented in the Procedure Call Standard for the ARM Architecture. One complicating factor is whether the calling convention your C compiler uses is the base standard or the VFP variant standard. Either way once you determine that you can find out what registers integer and floating point values (if any) are passed in by following the rules given in chapter 5. http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf – Ross Ridge Mar 16 '17 at 01:27
  • The compiler itself is a resource, whether or not you found it online, why not just ask the compiler, it knows the answer. – old_timer Mar 16 '17 at 02:20
  • 2
    Possible duplicate of [ARM to C calling convention, registers to save](http://stackoverflow.com/questions/261419/arm-to-c-calling-convention-registers-to-save) or looking at the AAPCS, r0-r3 are for integer types and s0–s15 (d0–d7, q0–q3) are for floats arguments. If you can not find space, they are put on the stack. Depends on ABI variant and co-processor. `printf()` (varadic functions) types are much different. – artless noise Mar 16 '17 at 14:44
  • `void foo(int, float, int, float);` should be the same as `void foo(int, int, float, float);` with regards to argument assignment AFAIU. – artless noise Mar 16 '17 at 14:54

0 Answers0