<article>
<title>cc65 internals
-<author><url url="mailto:brad@rainwarrior.ca" name="Brad Smith">
+<author><url url="mailto:bbbradsmith@users.noreply.github.com" name="Brad Smith">
<date>2016-02-27
<abstract>
<item><tt/cdecl/ - passes all parameters on the C-stack.
<p>
<item><tt/fastcall/ - passes the rightmost parameter in
- registers <tt>A/X/sreg</tt> an all others on the C-stack.
+ registers <tt>A/X/sreg</tt> and all others on the C-stack.
<p>
</itemize>
the <tt>A/X/sreg</tt> registers:
<itemize>
- <item><tt/A/ - 8-bit parameter, or low byte of larger tyes<p>
+ <item><tt/A/ - 8-bit parameter, or low byte of larger types<p>
<item><tt/X/ - 16-bit high byte, or second byte of 32-bits<p>
<item><tt/sreg/ - Zeropage pseudo-register including high 2 bytes of 32-bit parameter<p>
</itemize>
Example:
<tscreen><verb>
// C prototype
-void foo(unsigned bar, unsigned char baz);
+void cdecl foo(unsigned bar, unsigned char baz);
; C-stack layout within the function:
;
lda (sp),y ; Low byte now in A
</verb></tscreen>
-<sect1>Epilogue, after the functiona call<p>
+<sect1>Epilogue, after the function call<p>
-<sect2>Return requirements</p>
+<sect2>Return requirements<p>
If the function has a return value, it will appear in the <tt>A/X/sreg</tt> registers.
The internal pseudo-register <tt/regbank/ must not be changed by the function.
-<sect2>Clobbered state</p>
+<sect2>Clobbered state<p>
The <tt/Y/ register may be clobbered by the function.
The compiler will not depend on its state after a function call.
free use by any function called by C, and do not need to be preserved.
Note that if another C function is called from your assembly function,
it may clobber any of these itself:
+
<itemize>
<item><tt>tmp1 .. tmp4</tt><p>
<item><tt>ptr1 .. ptr4</tt><p>