This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Restoring Resister Values

Note: This was originally posted on 17th March 2011 at http://forums.arm.com

Hi,
I am working with Cortex M3 and I wrote a program in which I am calling a C function that is implemented in Assembly language. Four parameters are passed to the function, which are assigned to the Registers R0-R3. After performing some calculations on R0-R3 in the subroutine implemented in assembly language, when I return back to the C function the values of the R0-R3 are not the same as at the function's entry point rather R0-R3 contain results of the calculations performed in the subroutines. How can I get the same values back as they were at the starting point of the function call?
Looking forward for some useful hint.
Thanks and Regards
Parents
  • Note: This was originally posted on 17th March 2011 at http://forums.arm.com

    I think assembly functions perform operations based on the addresses. So if you use a register to perform an operation, the calculated value will be stored in the same address. To avoid that, once that register address is available, move the content of that register to another vacant address an perform your calculations on that address. That will leave the original register unchanged.
    I hope this answered your question.

    Best regards,
    Theesan.
Reply
  • Note: This was originally posted on 17th March 2011 at http://forums.arm.com

    I think assembly functions perform operations based on the addresses. So if you use a register to perform an operation, the calculated value will be stored in the same address. To avoid that, once that register address is available, move the content of that register to another vacant address an perform your calculations on that address. That will leave the original register unchanged.
    I hope this answered your question.

    Best regards,
    Theesan.
Children
No data