CPU uses stack to pass parameters and to save return address before jumping to next function call. It also uses stack memory for loading and storing local variables. Below is a stack grow example of a function call which has this following prototype-
Here we have a local variable Local. Program calls more and more inner functions, call frame grows. With the above prototype compiler pushes argument2 then argument1 and then call the function. Call instruction pushes the return address and further inside the function compiler pushes BP. Compiler will put local after this. Now as stack grows in a perticuler direction so after each and every inner function call, address of the local would be either increasing or decreasing position. If we compare the address values we would definitely get the direction details. Here is a small C code example. Here we are passing the address of a local of an outer function to an inner function call. Now as we called a function stack has grown. Next is compare the address of two locals.
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Memory leaks