From 6bc56335677514a1f508f1d83bdafbcc2f66c9f0 Mon Sep 17 00:00:00 2001 From: Oxore Date: Fri, 5 Jan 2024 22:59:05 +0300 Subject: Initial commit --- source/c-calling-conventions.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 source/c-calling-conventions.rst (limited to 'source/c-calling-conventions.rst') diff --git a/source/c-calling-conventions.rst b/source/c-calling-conventions.rst new file mode 100644 index 0000000..06ae61e --- /dev/null +++ b/source/c-calling-conventions.rst @@ -0,0 +1,22 @@ +C calling conventions +===================== + +cdecl (Windows X86) +------------------- + +Subroutine arguments are passed on the stack. + +Integer values and memory addresses are returned in the EAX register + +Registers EAX, ECX, and EDX are caller-saved, and the rest are callee-saved. [#wiki-call-conv]_ + +Other +----- + +GCC keeps stack aligned to 16 bytes because called function may be SSE2 instruction that requires alignment to 16 bytes. [#gcc-stack-alignment]_ + +Footnotes +--------- + +.. [#wiki-call-conv] https://en.wikipedia.org/wiki/X86_calling_conventions +.. [#gcc-stack-alignment] `StackOverflow: why does the compiler subtract value on ESP `_ -- cgit v1.2.3