Answer: On calling a function in the call by value method, we pass the values of the variables using stack. Before the function call is made, arguments are pushed to the stack. Stack will contain a duplicate variable which are usually the arguments.
Here is the block diagram describing disassembly steps, call stack and argument variables. Calling sum (a, b) can be split into some assembly steps like-
- push value of b
- push value of a
- save return address
- call function
Here one point to note is x and y are in stack. Value of a and b will be copied to x and y. Inside sum() value of x and y will be changed but it will not affect a and b in the main().
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