summaryrefslogtreecommitdiff
path: root/source/c-calling-conventions.rst
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2024-01-05 22:59:05 +0300
committerOxore <oxore@protonmail.com>2024-01-05 22:59:05 +0300
commit6bc56335677514a1f508f1d83bdafbcc2f66c9f0 (patch)
tree2c3dbfd32a8db416fa7231274781c20bfc260285 /source/c-calling-conventions.rst
Initial commit
Diffstat (limited to 'source/c-calling-conventions.rst')
-rw-r--r--source/c-calling-conventions.rst22
1 files changed, 22 insertions, 0 deletions
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 <https://stackoverflow.com/q/38128940>`_