2024-10-13 17:37:25 +00:00
|
|
|
%import textio
|
2024-10-18 18:53:30 +00:00
|
|
|
%import floats
|
2024-10-13 17:37:25 +00:00
|
|
|
%option no_sysinit
|
|
|
|
%zeropage basicsafe
|
|
|
|
|
2024-10-07 17:17:37 +00:00
|
|
|
main {
|
2024-10-16 16:36:19 +00:00
|
|
|
sub start() {
|
2024-10-17 23:29:51 +00:00
|
|
|
ubyte x = testdefer()
|
|
|
|
txt.print("result from call=")
|
|
|
|
txt.print_ub(x)
|
|
|
|
txt.nl()
|
2024-10-18 18:53:30 +00:00
|
|
|
float f = testdeferf()
|
|
|
|
txt.print("result from fcall=")
|
|
|
|
floats.print(f)
|
|
|
|
txt.nl()
|
|
|
|
|
|
|
|
floats.push(f)
|
|
|
|
txt.print("pushed f")
|
|
|
|
f = floats.pop()
|
|
|
|
floats.print(f)
|
|
|
|
txt.nl()
|
|
|
|
}
|
|
|
|
|
|
|
|
sub testdeferf() -> float {
|
|
|
|
defer {
|
|
|
|
txt.print("defer in floats\n")
|
|
|
|
}
|
|
|
|
float @shared zz = 111.111
|
|
|
|
cx16.r0++
|
|
|
|
return 123.456 + zz
|
2024-10-17 23:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub testdefer() -> ubyte {
|
2024-10-18 19:22:32 +00:00
|
|
|
ubyte @shared var = 22
|
2024-10-17 23:29:51 +00:00
|
|
|
|
|
|
|
defer txt.print("defer1\n")
|
|
|
|
defer {
|
|
|
|
txt.print("defer2, var=")
|
|
|
|
txt.print_ub(var)
|
|
|
|
txt.nl()
|
2024-10-18 19:22:32 +00:00
|
|
|
var=33
|
2024-10-17 23:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if var==22 {
|
|
|
|
var = 88
|
2024-10-18 19:22:32 +00:00
|
|
|
return var ; + other()
|
2024-10-16 23:43:33 +00:00
|
|
|
}
|
2024-10-17 23:29:51 +00:00
|
|
|
else {
|
|
|
|
var++
|
|
|
|
txt.print("var=")
|
|
|
|
txt.print_ub(var)
|
|
|
|
txt.nl()
|
|
|
|
return 255
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-10-18 18:53:30 +00:00
|
|
|
sub other() -> ubyte {
|
|
|
|
txt.print("other()\n")
|
|
|
|
return 11
|
2024-10-13 02:20:57 +00:00
|
|
|
}
|
2024-09-14 21:17:26 +00:00
|
|
|
}
|