task 3.3-3.4: x86 cdecl stub encoding + CallingConvention enum

Add CallingConvention enum (Cdecl, Stdcall, Thiscall, Fastcall).
Implement BuildCallStub on StubAssembler with x86 cdecl support:
reverse arg push, call rel32, add esp (caller cleanup), ret.
x64 stub is a placeholder (task 3.7-3.8).

3 new tests: 0-arg (call+ret), 1-arg (push+call+cleanup+ret),
2-args (reverse push+call+cleanup+ret). Known byte expectations.
All passing (total: 67).
This commit is contained in:
kbe
2026-07-21 19:37:20 +02:00
parent 855595837f
commit f7236eea9b
3 changed files with 163 additions and 11 deletions
+19
View File
@@ -0,0 +1,19 @@
namespace WhiteMagic.Assembly;
/// <summary>
/// x86/x86-64 calling conventions for call-stub generation.
/// </summary>
public enum CallingConvention
{
/// <summary>Caller pushes args right-to-left and cleans the stack (x86).</summary>
Cdecl,
/// <summary>Caller pushes args right-to-left; callee cleans the stack (x86).</summary>
Stdcall,
/// <summary>ECX receives the <c>this</c> pointer; remaining args on stack right-to-left; callee cleans (x86).</summary>
Thiscall,
/// <summary>ECX/EDX receive the first two args; remaining on stack right-to-left; callee cleans (x86).</summary>
Fastcall,
}