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:

  1. Stack is stored on.
  2. Returns the focus in the address stack or in the CPU register for a particular purpose.
  3. The location for the return is "allocated" on the stack.
  4. Function (address of address or in fact), either via a specific CPU via the call directive, or general jmp or <
  5. The function reads the argument (if any) from the "stack" and runs the function code
  6. Return value from the function is stored in the specified location (stack or special purpose CPU register)
  7. 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

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -