c++ - What happens in assembly language when you call a method/function? -
If I have a program in C ++ / C (there is no language in the language, then just clear a concept Is required to:)
#include & lt; Iostream & gt; Zero foo () {printf (in "foo"); } Int main () {foo (); Return 0; }
What happens in the assembly? I am not really looking for assembly code because I have not got it yet, but what is the basic principle?
In general, this happens:
- Stack is stored on.
- Returns the focus in the address stack or in the CPU register for a particular purpose.
- The location for the return is "allocated" on the stack.
- Function (address of address or in fact), either via a specific CPU via the
call
directive, or generaljmp
or <
- The function reads the argument (if any) from the "stack" and runs the function code
- Return value from the function is stored in the specified location (stack or special purpose CPU register)
- The execution jumps back to the collar and the stack is cleared (stack poin Restoring the tone to its initial value). The details of the above differ from platform to platform and even compiler to compiler (see SDDLL versus CDECL calling conferences for example). For example, in some cases, CPU registers are used instead of luggage storage on the stack. The general idea is the same, though
Comments
Post a Comment