prog8/examples/test.p8

64 lines
1.5 KiB
Plaintext
Raw Normal View History

2019-08-18 01:39:48 +02:00
%zeropage basicsafe
2019-08-09 02:15:31 +02:00
2019-08-25 00:24:00 +02:00
; TODO fix compiler errors:
; for bb in [1,2,3] -> byte loop variable can only loop over bytes
2019-08-25 00:46:46 +02:00
; for ww in [1111,3333,555,999] -> word loop variable can only loop over bytes or words
2019-08-25 00:24:00 +02:00
; for uw in 20 to 10 step -1 -> 'can't cast BYTE into UWORD'
2019-08-07 02:02:34 +02:00
main {
sub start() {
2019-08-25 00:24:00 +02:00
ubyte[] ubarr = [22,33,44,55,66]
byte[] barr = [22,-33,-44,55,66]
ubyte endub1
byte endb1
uword count
ubyte aa
ubyte ub
byte bb
word total
2019-08-19 22:28:41 +02:00
2019-08-21 00:09:44 +02:00
2019-08-25 00:46:46 +02:00
for count in 10 to 20 step 1 {
2019-08-25 00:24:00 +02:00
}
2019-08-25 00:46:46 +02:00
for count in 20 to 10 step -1 { ; @todo fix compiler error
2019-08-25 00:24:00 +02:00
}
; ---------- BYTE var ---------
; @todo fix byte loop in arrayliteral 'Error: byte loop variable can only loop over bytes'
count = 0
total = 0
2019-08-25 00:46:46 +02:00
c64scr.print("byte var in arrayliteral: ")
for bb in [1,3,5,99] {
2019-08-25 00:24:00 +02:00
count++
total += bb
}
2019-08-25 00:46:46 +02:00
if count==4 and total==108
2019-08-25 00:24:00 +02:00
c64scr.print("ok\n")
else
c64scr.print("fail!!!\n")
2019-08-25 00:46:46 +02:00
; ---------- WORD var ---------
2019-08-25 00:24:00 +02:00
2019-08-25 00:46:46 +02:00
word[] warr = [-111,222,-333,444]
word endw1
word ww
2019-08-25 00:24:00 +02:00
2019-08-25 00:46:46 +02:00
; @todo fix compiler error
2019-08-25 00:24:00 +02:00
count = 0
total = 0
2019-08-25 00:46:46 +02:00
c64scr.print("word var in arrayliteral: ")
for ww in [1111,3333,555,999] {
2019-08-25 00:24:00 +02:00
count++
2019-08-25 00:46:46 +02:00
total += ww
2019-08-25 00:24:00 +02:00
}
2019-08-25 00:46:46 +02:00
if count==4 and total==5998
2019-08-25 00:24:00 +02:00
c64scr.print("ok\n")
else
c64scr.print("fail!!!\n")
2019-08-24 16:21:05 +02:00
}
}