forgot to mention floats

This commit is contained in:
Irmen de Jong 2024-11-15 23:37:08 +01:00
parent 07158a6f1a
commit b9ad7e0e55
2 changed files with 14 additions and 8 deletions

View File

@ -144,11 +144,12 @@ Regular subroutines
- The arguments passed in a subroutine call are evaluated by the caller, and then put into those variables by the caller. - The arguments passed in a subroutine call are evaluated by the caller, and then put into those variables by the caller.
The order of evaluation of subroutine call arguments *is unspecified* and should not be relied upon. The order of evaluation of subroutine call arguments *is unspecified* and should not be relied upon.
- The subroutine is invoked. - The subroutine is invoked.
- The return value is not put into a variable, but the subroutine passes it back to the caller via cpu register(s): - The return value is not put into a variable, but the subroutine passes it back to the caller via register(s):
Byte values will be put in ``A`` .
Boolean values will be put in ``A`` too, as 0 or 1. - A byte value will be put in ``A`` .
Word values will be put in ``A`` + ``Y`` register pair (lsb in A, msb in Y). - A boolean value will be put in ``A`` too, as 0 or 1.
Float values will be put in the ``FAC1`` float 'register'. - A word 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'.
**Builtin functions can be different:** **Builtin functions can be different:**
some builtin functions are special and won't exactly follow these rules. some builtin functions are special and won't exactly follow these rules.
@ -167,6 +168,9 @@ Two byte parameters: ``sub foo(ubyte bar, ubyte baz) { ... }``
Single word parameter: ``sub foo(uword bar) { ... }`` 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 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*
Other: ``sub foo(ubyte bar, ubyte baz, ubyte zoo) { ... }`` Other: ``sub foo(ubyte bar, ubyte baz, ubyte zoo) { ... }``
register values indeterminate, values all get stored in the parameter variables *by the caller* register values indeterminate, values all get stored in the parameter variables *by the caller*

View File

@ -2,8 +2,9 @@
main { main {
sub start() { sub start() {
float zz
thing() thing()
thang() zz = thang(1.22)
bool status bool status
cx16.r0L, status = extfunction(42, 11223, 999, 1.22, true) cx16.r0L, status = extfunction(42, 11223, 999, 1.22, true)
cx16.r0L, status = function(42, 11223, 999, 1.22, true) cx16.r0L, status = function(42, 11223, 999, 1.22, true)
@ -18,8 +19,9 @@ main {
return true return true
} }
sub thang() -> float { sub thang(float arg) -> float {
arg++
return arg
} }
sub func1(ubyte arg) { sub func1(ubyte arg) {