Hello,
I was hoping someone could tell me how the memory works during functions call out of main.
In regular C and C++, after functions return, the memory is free again.
How does it work in the 8051 using C?
For example:
void myFunc() { int VAR = 1; }
When the function gets called does VAR use data memory or code memory? When it returns, is the memory that VAR used, free to be used again?
Thanks.
Thanks for the in depth reply.
To make sure I understand, the compiler will try to allocate a certain amount of memory to be reused/shared by functions? In that case, does that mean splitting your code into more functions with local variables can be better for managing DATA and XDATA memory than using global variables, considering the functions are not recursive or nested?
In that case, does that mean splitting your code into more functions with local variables can be better for managing DATA and XDATA memory than using global variables, considering the functions are not recursive or nested?
Not really. More functions actually increase the amount of automatic storage needed (for all those local things you would have to pass from one such function to the other).
In that case, does that mean splitting your code into more functions with local variables can be better for managing DATA and XDATA memory than using global variables and the only valid answer is: "that depends".
Erik