#25551 - Darmstadium - Tue Aug 24, 2004 11:39 pm
I'm trying to write a function is ASM and then call it using C code. I can call the function with no problems, but once i have i seem to have some problems. I know that in my ASM function I should back-up the values in registers 4-7 before using them. i try to push them on the stack like this:
the top line stores the address of the first of my arguments that were pushed on the stack when the function was called. now i try to access them like so:
Does the above code put the first argument in r4 and the second one in r5 and so on?
now i do all the fun stuff that my function does and am ready to return to the C code. First I have to restore the values of r4-r7 to what they were when my asm function was called. i try to do that like this:
Have i done this correctly? i seem to have a problem when running my c code after my asm function is done executing.
Thanks for your help!
Code: |
mov r12,sp stmfd sp!,{r4} stmfd sp!,{r5} stmfd sp!,{r6} stmfd sp!,{r7} |
the top line stores the address of the first of my arguments that were pushed on the stack when the function was called. now i try to access them like so:
Code: |
ldmfd r12!,{r4} ldmfd r12!,{r5} ldmfd r12!,{r6} ldmfd r12!,{r7} |
Does the above code put the first argument in r4 and the second one in r5 and so on?
now i do all the fun stuff that my function does and am ready to return to the C code. First I have to restore the values of r4-r7 to what they were when my asm function was called. i try to do that like this:
Code: |
ldmfd sp!,{r7} ldmfd sp!,{r6} ldmfd sp!,{r5} ldmfd sp!,{r4} |
Have i done this correctly? i seem to have a problem when running my c code after my asm function is done executing.
Thanks for your help!