prog8/examples/test.p8

66 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-10-27 20:50:48 +00:00
%import textio
%option no_sysinit
2024-11-08 18:43:59 +00:00
%zeropage basicsafe
; INIT ONCE tests
2024-10-18 20:22:34 +00:00
main {
2024-11-04 23:15:40 +00:00
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()
2024-11-04 23:15:40 +00:00
txt.nl()
2024-11-08 18:43:59 +00:00
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()
}
}
2024-11-08 18:43:59 +00:00
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++
}
}