update docs about call convention for multi-value results (first is in A or AY, then R15...R0)

added sprites+coroutines+defer part to benchmark program
This commit is contained in:
Irmen de Jong
2025-02-19 21:05:33 +01:00
parent bc550a4549
commit fb1e89d9ef
7 changed files with 20 additions and 14 deletions
+2 -2
View File
@@ -1170,9 +1170,9 @@ So for instance::
asmsub multisub() -> uword @AY, bool @Pc, ubyte @X { ... }
.. sidebar:: usage of cx16.r0-cx16.r15
.. sidebar:: register usage
Subroutines with multiple return values use the "virtual registers" to return those.
Subroutines with multiple return values use cpu registers A, Y, and the R0-R15 "virtual registers" to return those.
Using those virtual registers during the calculation of the values in the return statement should be avoided.
Otherwise you risk overwriting an earlier return value in the sequence.
+3 -2
View File
@@ -155,8 +155,9 @@ Regular subroutines
- for an ``asmsub`` or ``extsub`` the subroutine's signature specifies the output registers that contain the values explicitly,
just as for a single return value.
- for regular subroutines, the compiler will use the "virtual registers" cx16.r0-cx16.r15, from r15 down to r0, for the
result values left to right. This may change in a future compiler version.
- for regular subroutines, the compiler will return the first of the return values via the cpu register ``A``` (or ``A + Y``` if it's a word value),
just like for subroutines that only return a single value.
The remainder of the return values are returned via the "virtual registers" cx16.r16-cx16.r0 (using R15 first and counting down to R0).
**Builtin functions can be different:**
-4
View File
@@ -1,10 +1,6 @@
TODO
====
- IR: call main.two():r4.w,r5.w the registers mentioned after the call are wrong/unused in case of multi-value returns. Better to clear this to avoid confusion? (they ARE correct for single value returns!)
- update docs about call convention for multi-value results (first is in A or AY, then R15...R0)
...