We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Say I have a function:
unsigned char* func1(unsigned char param1, signed int param2);
That would be an ASM function being called from C. The actual parameters and return type are rather irrelevant, and are just presented as an example.
Can it be guaranteed that the storage of the parameters passed to the function will not change, provided I do not change the prototype?
For my question, please assume that the toolchain does not change. (i.e. No upgrades/updates to C51)
I'm just told by the manual to make the function in C, then repeat in assembly how it appears in the compiler assembly listing. I really need to be able to assume that once I create the ASM function and the C function prototype, that that is totally stable in it's current format, even if I rebuild the entire project.
Further questions for anyone who knows: *Is it written anywhere on if the internal ABI may change with future versions? *Is the ABI anywhere? As I said, I can only find a statement of what amounts to: Try it and make it match what the C compiler does.
The function calling convention remains stable as long as you do not change the prototype.
I don't know that Keil promises _never_ to change the ABI, but they certainly don't do so often. And since it would invalidate all their own libraries in addition to annoying customers, I doubt they're likely to change (even where they could make some improvements).
The function calling convention is documented in the C51 manual. See the "Interfacing C to Assembler" section.
http://www.keil.com/support/man/docs/c51/c51_ap_funcparam.htm
I think the rules are clear enough that I just code my assembler functions that way. I don't really feel the need to create a C skeleton and run that through the compiler. That's a handy fallback if the parameters don't seem to show up where you expect, though.