Home > Back-end >  Clear __stdcall with variable and function of the stack
Clear __stdcall with variable and function of the stack

Time:05-15

I there are two main problems:
1. About the variable and function, whether no matter what statement calling convention, it will be implemented as __cdecl? Below is a VC assembly, is actually specify __stdcall,


2. How to stack cleaning way of GCC and VC is not the same? Or is this a stack cleanup?


Looked at it several times to call, every time find it pass all armed with the same period of repeated use of space, into the stack is the picture of that, the different function call, the arguments are in the same period, as the caller to control the spread of refs stack space, also is to do stack cleanup? Or it can stack cleanup?

(compiled using 32-bit, x64 agreement)

CodePudding user response:

1. The stdcall calling conventions such as the rules of the limits for the use of variable and function, they, of course, there are some special circumstances,
2. The stack to clear what is it?? Parameter passing in and out of the stack? GCC and vc transfer when the use of the stack is basically the same, only the GCC allocated space and vc with push ahead of time, but after each use of the stack is balanced,

CodePudding user response:

refer to the building of six Payne reply:
I there are two main problems:
1. About the variable and function, whether no matter what statement calling convention, it will be implemented as __cdecl? Below is a VC assembly, is actually specify __stdcall,
2. How to stack cleaning way of GCC and VC is not the same? Or is this a stack cleanup?
Looked at it several times to call, every time find it pass all armed with the same period of repeated use of space, into the stack is the picture of that, the different function call, the arguments are in the same period, as the caller to control the spread of refs stack space, also is to do stack cleanup? Or it can stack cleanup?
(compiled in 32-bit, x64 convention)

1, with variable function, its calling conventions only as __cdecl, because only the caller know how many parameters, the callee can not know (except mark meaningful parameters), so at this time also can only be done by the caller stack cleaning, back to the state before the call
2, each and all of them in the same period of repeated use of space, this itself is the way to handle it, the stack is the place that is better than that of pile, after each function call, will return to the state before the call, so the stack normally does not need special space, functional programming in the tail recursive way is the best use of stack
3, whether the calling convention, as long as every time after the function call will restore to the state before the call stack, stack can be considered to be clear, also called the stack balancing
  • Related