"The feature of C language from right to left into Stack enables it to implement variable-length parameter functions such as printf"
This is a true proposition. I checked some materials at night and summarized them as follows:
(1) differences between the variable length parameter list and fixed parameters:
Most of the functions we write are fixed parameter functions (at least I have not written a variable-length function). After compilation, the address of the form parameter is fixed, and the called function also knows the address of the form parameter, so the value can be correct. For example, int func (int A, int B)
(2) How does the printf () Variable Length Parameter take the value?
In the prototype of the printf function, the first parameter is unchanged and must be a format string. the number and content of the subsequent parameters depend on the content of the first parameter, which is also called the variable length parameter. In the implementation of printf, it is not difficult to see that the called function can determine the parameter type and number only after obtaining the first parameter, therefore, the compiler must place the first parameter in a fixed position. This location is % EBP + 8.
After the func function is called, % EBP, % ESP registers point to memory units, % EBP + 8 points to the first parameter & arg1. (the format string in the printf function). If the stack is pressed from left to right, the first parameter is not at the top of the stack, but at the bottom of the stack, you cannot know its specific location.
In short, the C language specifies that the function pressure stack sequence is from right to left, so that the first parameter is always at the top of the stack that calls the function, and the called function can always get it correctly, to continue to take other parameters.