There are two ways to pass the parameters in C language: one is to pass the form of a stack. There is also a way to pass through registers.
This. We're just describing the first way to pass the number of passes, and the second way is not specifically described here.
First, let's take a look at one of the following simple invocation routines:
int Add (int a, int b, int c)
{
return a+b+c;
}
void Main ()
{
int x =0, y = 1, z = 2;
int result = 0;
result = Add (x, y, z);
printf ("Result for x+y+z%d", result);
}
With these routines, we'll look at how the parameters are passed.
First of all. We understand a knowledge point, that is, the "()" operator in C language has a lot of meaning, for example, binding characters, function calls and so on.
The result = Add (x, y, z) statement is, of course, a function call, so in the compile phase, the run-time after the function call is encountered, starting with the last parameter. The stack order is z->y->x until all of the references are pressed into the call stack and then called to add the corresponding function address to start running. After the press stack has finished running. Stack space, from top to bottom in order of x->y->z (because the stack is growing in the direction of upward, that is, the address is low, so x in the lowest address, that is, the top of the stack). So. The reading and manipulation of the parameters in the called function are also occurring in the stack.
The principle of C-language function parameters transfer