In the future, technical notes will be recorded on this blog.
When I encountered this problem during compilation principles today, I sorted it out.
The parameter pressure stack and rollback methods are determined by the function call specification.
Most function call parameters are pushed from right to left to stack, because we read the parameters from left to right.
Common call specifications for Windows:
Call Specification
Description
_ Cdecl
The default call specification for C/C ++ programs. Parameters are transferred from right to left, and the call function is responsible for moving the parameters from the stack. This facilitates passing a variable number of parameters.
_ Stdcall
The call specification used by this WindowAPI function. The parameter is transferred from right to left, and the called function is responsible for removing the parameter from the stack. The code generated by this specification is smaller than _ cdecl, but the _ cdecl specification will still be used when the function has variable parameters. WINAPI, CALLBACK, and APIENTRY macros are defined as _ stdcall specifications.
Thiscall
(Non-Keyword)
The default call specification for C ++ member functions. variable parameters are not used. Except that the this pointer is saved in the ECX register rather than in the stack, the others are the same as _ stdcall. Note: Use the _ stdcall specification for COM member functions