Re: Heap/Stack
The stack is used for passing and returning arguments to functions and for local function variables. The function creates a stack frame for this, which helps it use the stack as fast local memory for storing tempary variables and then restore the stack when it is done. The stack grows up or down as functions call functions etc.
The stack has a defined size allacated by you or the compiler/linker.
An area of memory is set aside for storing global variables, arrays, constants etc.
This is done by the linker. If you have a linker script, you can edit this.
The heap is the free memory left. It usually grows in the opposite direction to the stack so they meet in the middle. If you dynamicaly allocate memory using malloc you are using the heap.