On Apr 20, 5:33 pm, Terence <spamt...@[EMAIL PROTECTED]
> wrote:
> An interesting point in Frank Kotler's posting, is who gets to clean
> up the stack.
> Here Frank is doing it in the main program (obviously because the
> called rountines don't do this for him).
> But I was "brought up" on the Microsoft standard of the CALLED
> subprogram doing a RET N operation to clear the stack. All my hand-
> wriiten subroutine include this, beuase my main program is a Microsoft
> Fortran program which folows my description of the stack
> responsibility.
>
> So I assume Miscroft chnaged it's mind at some point in time, because
> obvious again, the referred called services aboove are Microsoft-
> written Windows service.
Win16 has always used what MS has called the Pascal calling
convention, and Win32 uses stdcall. Both of those are callee cleanup,
but stdcall p***** parameters right-to-left (like cdecl), unlike
Pascal (which is left-to-right). C compilers use cdecl (which is
right-to-left and caller cleanup) by default. Left-to-right and
callee cleanup are both problems for C-style variable argument lists.
It is fairly conventional in Windows to make all API-style functions
(including most things ex****ted from DLLs) use Pascal or stdcall as
appropriate for the system, although there is absolutely nothing
enforcing that, and in fact, the shared (DLL) versions of the CRT
supplied by MS use cdecl conventions for the C library functions.
Win64 uses a variation of the old fastcall convention for both intra-
program calls and API calls, which is also the case for most *nix
systems (IOW, the same calling convention is used intra- and inter-
program, but it’s not the same as the Win64 conventions). That does
simplify things.
And the convention moves around a bit for non-x86 platforms.


|