Analyze

xiaoxiao2021-03-17  180

In the function call, the stack is used, which represents different stack call modes and release methods. For example, __cdecl, it is a stack call mode of the standard C method, which is the opposite of the parameters when the function call is in the order of the function, and the other two can see MSDN, but this is not too big for us. Role

Call agreement

Calling Convention Decides the following: The stack order of the function parameters, pops the arguments by the caller or by the caller, and the method of generating a function modifier. MFC supports the following calls:

_CDECL

Pressing parameters from right to left, pops up the argument by the caller. For "C" functions or variables, the modifier is in front of the function name. For the "C " function, it is different.

If the modulation of the function void test (void) is _TEST; for the "C " global function that does not belong to a class, the modifier name is? Test @@ zaxxz.

This is an MFC default call convention. Since the caller is responsible for popping the argument, you can define a number of non-number parameters, such as the Printf function.

_stdcall

Pressing the parameters from right to left, and pops up the argument by the caller. For "C" functions or variables, the modulation name is prefixed, then the function name, then the number of the symbol "@" and parameters, such as the function INT FUNC (Int A, Double B) is _func @ 12. The "C " function is different.

All Win32 API functions follow this agreement.

_fastcall

Two DWORD types or parameters accounting for less bytes are placed in ECX and EDX registers, and the other remaining parameters are pressed into the stack from right to left. By popping the parameters by the caller, the "C" function or variable, the modulation name is prefixed in "@", then the function name, then the number of the symbol "@" and parameters, such as the function int func (int A, Double B) is called @ func @ 12. For the "C " function, it is different.

Future compilers may use different registers to store parameters.

转载请注明原文地址:https://www.9cbs.com/read-129609.html

New Post(0)