I am trying to pass more than four parameters from my C++ code to Assembly.
The C++ function looks like :
static float armFunction(float, float, float, float, float);
I can retrieve the first four parameters from the registers r0-r3 without any problem.
I expect that my fifth float argument is on the stack and i should be able to access it using the stack pointer sp e.g. I try to load my fifth argument in r4 like :
ldr r4, [sp]
or even:
ldr r4, [sp, #-0x4]
But this doesn’t work and the assembly code immediately exits with some stack corruption output.
My complete assembly code looks like this here: http://pastie.org/3933875
My asm code has no trouble reading the 5th parameter from a JNI call from C to asm. Here are the first 2 lines of my asm function:
In the case where you’re not needing to preserve any registers, the 5th parameter is on the top of the stack: