Passing more than four arguments to a function called through a wrapper function written using inline assembly in ARM clang 6.6

  arm, armclang, assembly, c++

I am trying to create wrapper functions around functions provided by the RTOS. In the wrapper function I use inline assembly in order to call software interrupt instruction (SVC) so that processor jumps to the SWI handler which further calls the actual OS function by first extracting the SWI number and then indexing into the SWI table using that number.

The prototype of wrapper function is exactly same as OS function so that all the arguments passed to the wrapper function are forwarded to the OS function exactly in the same order. This is all simple when function has less than or equal to four arguments and hence are passed through registers R0-R3. Something like this :

std::uint32_t wrapper_function(std::uint32_t a1, std::uint32_t a2, std::uint32_t a3, std::uint32_t a4)
    std::uint32_t ret {};

    __asm volatile(
        "SVC 0x05"
        : "=r" (ret)
        : "r" (a1), "r" (a2), "r" (a3), "r" (a4)
        : "r14");

    return ret;

But when function has more than 4 arguments and since all arguments after the fourth are passed through stack, how to forward those arguments?

I am using ARM Compiler 6.6 (ARM Clang 6.6) and the system I am working on has ARM Cortex R5 processor.

Source: Windows Questions C++