prog8/examples/test.p8
Irmen de Jong 38ef394e15 IR codegen: global vars with numeric initialization value are now also put into the VARIABLESWITHINIT section rather than requiring explicit code instructions to initialize them in INITGLOBALS.
Note that something similar, such as putting those variables inline in the program initialized with their value and all, cannot be done for the 6502 codegen: the program needs a mechanism to reset ALL variables when it runs a second time.
2024-10-16 22:15:51 +02:00

40 lines
971 B
Lua

%import textio
%option no_sysinit
%zeropage basicsafe
main {
bool[] barray = [true, false, true, false]
uword[] warray = [&value1, &barray, &value5, 4242]
ubyte @shared integer = 99
bool @shared value1
bool @shared value2 = barray[2] ; should be const!
bool @shared value3 = true
bool @shared value4 = false
bool @shared value5 = barray[cx16.r0L] ; cannot be const
uword @shared value6 = warray[3] ; should be const!
uword @shared value7 = warray[2] ; cannot be const
sub start() {
txt.print_ub(integer)
integer++
txt.spc()
txt.print_ub(integer)
txt.nl()
txt.print_bool(value1)
txt.spc()
txt.print_bool(value2)
txt.spc()
txt.print_bool(value3)
txt.spc()
txt.print_bool(value4)
txt.spc()
txt.print_bool(value5)
txt.spc()
txt.print_uw(value6)
txt.nl()
}
}