Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
int x = 6;
int x;
void myFunction(void){ // Start block level 1 int x; { // Start block level 2 int y; // do something with 'y' } // End block level 2 { // Start block level 2 int z; // do something with 'z' } // End block level 2} // End block level 1
struct myFunctionData { int x; // always existss union { int y; int z; };}
1) If I never use dynamic memory allocation, then the heap will only store global variables.
2) All local variables are pushed onto the stack
d) The above assumed that no dynamic memory allocation occurred
foo = malloc(10);
3) There is no memory manager on an ATMega
void foo(void){ int *x = malloc(sizeof(int)); *x = 4;i nt y = *x;}
SP = SP-4; // make space on the stack for local vars x and y SP[0] = malloc(2); // x = malloc *(SP[0]) = 4; // assign value to x SP[2] = *(SP[0]); // y = *x SP = SP + 4; // Discard local x,y variables
I can imagine that y, being statically allocated, always resides in a known address and so the hex file may contain a static reference to it
Where do I learn this stuff?