prog8/examples/test.p8
Irmen de Jong 3ee6058524 todo
2024-11-08 19:57:38 +01:00

66 lines
1.3 KiB
Lua

%import textio
%option no_sysinit
%zeropage basicsafe
; INIT ONCE tests
main {
sub start() {
uword w0
uword @initonce w1
uword @initonce w2
uword @initonce w3
uword @initonce w4 = 12345
uword[4] wa
uword[] @shared wb = [1111,2222,3333,4444]
dump()
txt.nl()
w0++
w1++
w2++
w3++
w4++
wa[1]++
wa[2]++
wa[3]++
wb[0]++
dump()
txt.nl()
repeat 10 {
footgun()
}
txt.nl()
sub dump() {
txt.print_uw(w0)
txt.spc()
txt.print_uw(w1)
txt.spc()
txt.print_uw(w2)
txt.spc()
txt.print_uw(w3)
txt.spc()
txt.print_uw(w4)
txt.spc()
txt.print_uw(wa[1])
txt.spc()
txt.print_uw(wa[2])
txt.spc()
txt.print_uw(wa[3])
txt.spc()
txt.print_uw(wb[0])
txt.nl()
}
}
sub footgun() {
; TODO should just be a nonlocal variable outside of the subroutine...?
ubyte @shared @initonce @requirezp variable = 42 ; BUG: is never initialized now
txt.print_ub(variable)
txt.spc()
variable++
}
}