As I can see, the keil compiler doesnt use regular stack for functions, and all the local variables inside functions are mapped in global memory. Is there a way, to make it behaive like a normal program should? I.E - create a local variables in ram,and destroy them, when the function ends? Thank you.
"As I can see, the keil compiler doesnt use regular stack for functions" It uses the stack for return addresses, and a few other things "all the local variables inside functions are mapped in global memory." and possibly some parameters, too. "Is there a way, to make it behaive like a normal program should?" What do you mean, "should"? There is nothing in the ANSI spec that requires any specific implementation of this! C51 works the way it does because of the nature of the 8051 processor. You can fight this if you wish, but you will get grossly inefficient code! Look up the 'reentrant' keyword extension... "create a local variables in ram,and destroy them, when the function ends?" The stack is still in RAM whichever way you do it! Also, stack-based compilers do not "destroy" variables when a function exits: the data remains in RAM (on the stack) - only the stack pointer is changed. This is why uninitialised variables can be so much fun... The way C51 works is effectively just having the tools do at build time what "conventional" implementations do on the stack at run time!
Yes,Adny - thank you. I understand, that nothing left to do, but to live with this.