Hi, I'm studying book "Thinking in C++", I suppose most of you have read it already.
In chapter 11 references & copy-constructor there is an interesting explanation of
function call with help of assembler code:
"To understand the need for the copy-constructor, consider the way C handles passing and returning variables by value during function calls. If you declare a function and make a function call,
int f(int x, char c);
int g = f(a, b);
how does the compiler know how to pass and return those variables?"
"If you figure out how to generate assembly code with your compiler and determine the statements generated by the function call to f( ), you’ll get the equivalent of:
mov g, register a"
It is pretty much clear to me what this represents except the following:
"The calling code is responsible for cleaning the arguments off the stack (which accounts for the add sp,4)"
What does this cleaning from the stack" mean? I'm not familiar with details of assembler but
I suppose add means adding so what is that all about cleaning? Those variables are supposed to stay on stack.
What instruction add sp,4 really means?
What is sp? Is it a name of CPU register?
Do you know any good introduction to assembler for C/C++ programmers(beginner/intermediate level)?
This is little confusing, so please help
Thank you very much for help!