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).
20 lines
634 B
C#
20 lines
634 B
C#
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,
|
|
}
|