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

Storing register values on stack at entry of a function.

I am using keil uVision4 for compiling the code. I found in the compiled code that for the nested functions all the working registers and LR is pushed on stack and popped back just before the return is executed. For non-nested functions the registers are not stored on stack. But I want that at every function entry, whether it be nested or not, these registers and LR to be saved on stack. How do I do it? What settings I have to do?

Thanks,
Bharat

Parents
  • And the reason for the huge amount of calling conventions supported by the Watcom compiler was to use it to call code written in foreign languages.

    It isn't as likely, in an embedded environment, that you need to call code compiled with a different compiler. Projects are smaller than on a PC. And most people have so much invested in their proprietary hardware that they don't dare to use libraries they don't have the full source code for. Which is also a reason why people have been avoiding some of the Keil libraries like the plague.

    But the main reason for a compiler switch to always force a standard stack frame isn't so much compatibility with foreign code. A standard stack frame means larger/slower code. But have the advantage that an exception handler can perform a walk of the stack all the way back to main() - so it can be a huge advantage when trying to figure out exactly where a program went nuts.

Reply
  • And the reason for the huge amount of calling conventions supported by the Watcom compiler was to use it to call code written in foreign languages.

    It isn't as likely, in an embedded environment, that you need to call code compiled with a different compiler. Projects are smaller than on a PC. And most people have so much invested in their proprietary hardware that they don't dare to use libraries they don't have the full source code for. Which is also a reason why people have been avoiding some of the Keil libraries like the plague.

    But the main reason for a compiler switch to always force a standard stack frame isn't so much compatibility with foreign code. A standard stack frame means larger/slower code. But have the advantage that an exception handler can perform a walk of the stack all the way back to main() - so it can be a huge advantage when trying to figure out exactly where a program went nuts.

Children