The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: tathams on April 07, 2006, 02:30:01 PM

Title: When must I cleanup to adjust the stack Pointer
Post by: tathams on April 07, 2006, 02:30:01 PM
From reading various docs I understand that different calling conventions require the caller or the callee to adjust the stack pointer before returning or just after returning from a function call.

If I use the Invoke SomeFunction, PARAM1, PARAM2 etc  macro type of calling things do I have to do anything afterwards.

Many of these functions are stdcall which I think will cleanup after themselves but others might be C or syscall or PASCAL.

Thanks in advance for you help

Title: Re: When must I cleanup to adjust the stack Pointer
Post by: BogdanOntanu on April 07, 2006, 04:54:42 PM
Theoretically, IF you define the function prototype corectly, the assembler will do this for you.
(ie it will clear the stack acording to the function's calling convention)

In Win32 API wsprintf is notorious CDECL, all other API is STDCALL.
Title: Re: When must I cleanup to adjust the stack Pointer
Post by: tathams on April 08, 2006, 04:18:33 AM
Excellent. Another reason to use all of the features of a modern assembler.