fix code size regressions

This commit is contained in:
Irmen de Jong
2025-08-14 23:37:59 +02:00
parent 4ea8b4d445
commit 729efb04e1
7 changed files with 30 additions and 16 deletions

View File

@@ -153,7 +153,7 @@ Regular subroutines
- A byte value will be put in ``A`` .
- A boolean value will be put in ``A`` too, as 0 or 1.
- A word value will be put in ``A`` + ``Y`` register pair (lsb in A, msb in Y).
- A word or pointer value will be put in ``A`` + ``Y`` register pair (lsb in A, msb in Y).
- A float value will be put in the ``FAC1`` float 'register'.
- In case of *multiple* return values:
@@ -171,7 +171,7 @@ Regular subroutines
some builtin functions are special and won't exactly follow these rules.
**Some arguments will be passed in registers:**
For single byte and word arguments, the values are simply loaded in cpu registers by the caller before calling the subroutine.
For single byte, word, and pointer arguments, the values are simply loaded in cpu registers by the caller before calling the subroutine.
*The subroutine itself will take care of putting the values into the parameter variables.* This saves on code size because
otherwise all callers would have to store the values in those variables themselves.
Note that his convention is also still used for subroutines that specify parameters to be put into
@@ -187,6 +187,9 @@ Two byte parameters: ``sub foo(ubyte bar, ubyte baz) { ... }``
Single word parameter: ``sub foo(uword bar) { ... }``
gets bar in the register pair A + Y (lsb in A, msb in Y), *subroutine* stores it into parameter variable
Single pointer parameter: ``sub foo(^^ubyte bar) { ... }``
gets bar in the register pair A + Y (lsb in A, msb in Y), *subroutine* stores it into parameter variable
Floating point parameter: ``sub foo(float bar) { ... }``
value for bar gets copied into the parameter variable *by the caller*

View File

@@ -5,8 +5,6 @@ TODO
STRUCTS and TYPED POINTERS (6502 codegen specific)
--------------------------------------------------
- fix code size regression. (for instance rockrunner is 200 bytes larger than before)
- fix struct allocations/inits.
- prefixSymbols(): what to do with prefixing struct fields? Should they be prefixed with something or no?
@@ -17,4 +15,4 @@ STRUCTS and TYPED POINTERS (6502 codegen specific)
- update structpointers.rst docs with 6502 specific things?
- scan through 6502 library modules to change untyped uword pointers to typed pointers
- scan through 6502 examples to change untyped uword pointers to typed pointers
- fix code size regressions (if any)