Search code examples
armneonds-5

DS5 Ultimate edition different behavior while accessing first float argument passed to asm call


I am using DS5 ultimate edition for assembly coding and execution on cortex-a53 32 bit. From my C function i am calling asm function. The usual norm is when from C function asm function is called and arguments passed, the first float argument is present in s0 register. For eg., func_asm(float a, float * b); First float argument 'a' goes to s0 register and argument 'b' is present in r0 register. But, in my case i am getting the first float argument 'a' in r0 register and 'b' in r1 register. I am using make file build with below options --target=arm-arm-none-eabi -march=armv7-a -mcpu=cortex-a53 -mfpu=neon Please suggest what option needs to be added to get the first float argument correctly in s0 register.


Solution

  • You will have to put the hard/soft float option for the ARM compiler (a Clang fork)

    In GCC/Clang, they look like following:

    • -mfloat-abi=hard
    • -mfloat-abi=softfp
    • -mfloat-abi=soft

    hard: it's what you are looking for. The compiler will generate machine codes that fully utilize the VFP

    softfp: The most commonly used form. Even though the VFP is utilized, the parameter passing occurs via the integer registers

    soft: No VFP utilization

    Beware that the hard option you intend to use isn't that commonly used. And your binaries won't even link to other ones compiled with the softfp/soft option.

    I strongly advise NOT use the hard option unless you know what you are doing.