Calling conventions
+
+There are two calling conventions used in cc65:
+
+
+ -
+
- A/X/sreg an all others on the C-stack.
+
+
+
+The default convention is Prologue, before the function call
+
+If the function is declared as fastcall, the rightmost argument will be loaded into
+the A/X/sreg registers:
+
+
+ -
+
-
+
-
+
+
+All other parameters will be pushed to the C-stack from left to right.
+The rightmost parameter will have the lowest address on the stack,
+and multi-byte parameters will have their least significant byte at the lower address.
+
+The
+// C prototype
+void foo(unsigned bar, unsigned char baz);
+
+; C-stack layout within the function:
+;
+; +------------------+
+; | High byte of bar |
+; Offset 2 ->+------------------+
+; | Low byte of bar |
+; Offset 1 ->+------------------+
+; | baz |
+; Offset 0 ->+------------------+
+
+; Example code for accessing bar. The variable is in A/X after this code snippet:
+;
+ ldy #2 ; Offset of high byte of bar
+ lda (sp),y ; High byte now in A
+ tax ; High byte now in X
+ dey ; Offset of low byte of bar
+ lda (sp),y ; Low byte now in A
+
+
+Variadic functions push all parameters exactly as other Epilogue, after the functiona call
+
+Return requirements
+
+If the function has a return value, it will appear in the A/X/sreg registers.
+
+Functions with an 8-bit return value (A/X/sreg, so these may be clobbered by the function.
+
+The C-stack pointer Clobbered state