mirror of
https://github.com/irmen/prog8.git
synced 2025-01-03 06:29:54 +00:00
forgot to mention floats
This commit is contained in:
parent
07158a6f1a
commit
b9ad7e0e55
@ -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 order of evaluation of subroutine call arguments *is unspecified* and should not be relied upon.
|
||||
- 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):
|
||||
Byte values will be put in ``A`` .
|
||||
Boolean values will be put in ``A`` too, as 0 or 1.
|
||||
Word values will be put in ``A`` + ``Y`` register pair (lsb in A, msb in Y).
|
||||
Float values will be put in the ``FAC1`` float 'register'.
|
||||
- The return value is not put into a variable, but the subroutine passes it back to the caller via register(s):
|
||||
|
||||
- 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 float value will be put in the ``FAC1`` float 'register'.
|
||||
|
||||
**Builtin functions can be different:**
|
||||
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) { ... }``
|
||||
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) { ... }``
|
||||
register values indeterminate, values all get stored in the parameter variables *by the caller*
|
||||
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
float zz
|
||||
thing()
|
||||
thang()
|
||||
zz = thang(1.22)
|
||||
bool status
|
||||
cx16.r0L, status = extfunction(42, 11223, 999, 1.22, true)
|
||||
cx16.r0L, status = function(42, 11223, 999, 1.22, true)
|
||||
@ -18,8 +19,9 @@ main {
|
||||
return true
|
||||
}
|
||||
|
||||
sub thang() -> float {
|
||||
|
||||
sub thang(float arg) -> float {
|
||||
arg++
|
||||
return arg
|
||||
}
|
||||
|
||||
sub func1(ubyte arg) {
|
||||
|
Loading…
Reference in New Issue
Block a user