<div dir="auto"><div>Here is what I found, experts please double-check (and I only looked up x86):<div dir="auto"><br></div><div dir="auto">The Windows API uses the stdcall calling convention, which has the same argument order and register preservation rules as cdecl, but the callee is responsible to pop arguments from the stack.</div><div dir="auto"><br></div><div dir="auto">In IA32FFIPlugin there is a macro PLATFORM_API_USES_CALLEE_POPS_CONVENTION, which is only 1 on Windows. If this is 1 and apicall is used (isCalleePopsConvention), the foreign function invocation code knows that the callee modifies the stack pointer and reacts accordingly.</div><div dir="auto"><br></div><div dir="auto">So, apicall does stdcall instead of cdecl on Windows, but not on the other x86 platforms.</div><div dir="auto"><br></div><div dir="auto">Stdcall is not the same as the Pascal calling convention, which pushes arguments from left to right, contrary to cdecl and stdcall, which push from right to left.</div><div dir="auto"><br></div><div dir="auto">Best,</div><div dir="auto">Jakob</div><br><div class="gmail_extra"><br><div class="gmail_quote">Am 04.08.2017 3:45 vorm. schrieb "tim Rowledge" <<a href="mailto:tim@rowledge.org">tim@rowledge.org</a>>:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Whilst looking at ancient OpenGL code I noted that many primitive calls used apicall and not cdecl. The swiki entry (<a href="http://wiki.squeak.org/squeak/2426" rel="noreferrer" target="_blank">http://wiki.squeak.org/<wbr>squeak/2426</a>) for FFI is… vague, and explicitly mentions confusion about the matter. It wold be nice to clear this up, document it on the swiki and maybe even make a Help page to go into the image.<br>
<br>
tim<br>
--<br>
tim Rowledge; <a href="mailto:tim@rowledge.org">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" rel="noreferrer" target="_blank">http://www.rowledge.org/tim</a><br>
Strange OpCodes: MII: Mask all Interrupts and then Interrupt<br>
<br>
<br>
<br>
</blockquote></div><br></div></div></div>