prog8/examples/test.p8

86 lines
1.9 KiB
Plaintext
Raw Normal View History

2019-07-01 21:41:30 +00:00
%import c64utils
%zeropage basicsafe
2019-03-29 01:13:28 +00:00
~ main {
2019-07-08 13:13:24 +00:00
sub start() {
ubyte aa = 100
ubyte yy = 22
uword uw = (aa as uword)*yy
2019-07-09 02:09:29 +00:00
c64scr.print("stack (255?): ")
c64scr.print_ub(X)
c64.CHROUT('\n')
2019-07-09 07:02:56 +00:00
aa=30
yy=2
c64scr.print_ub(7)
c64scr.print("?: ")
check(3, 4)
c64scr.print_ub(aa+yy)
c64scr.print("?: ")
check(aa, yy)
aa++
c64scr.print_ub(aa+yy)
c64scr.print("?: ")
check(aa, yy)
aa++
c64scr.print_ub(aa+yy)
c64scr.print("?: ")
check(aa, yy)
c64scr.print_uw(uw)
c64scr.print("?: ")
checkuw(uw)
uw++
c64scr.print_uw(uw)
c64scr.print("?: ")
checkuw(uw)
uw++
c64scr.print_uw(uw)
c64scr.print("?: ")
checkuw(uw)
c64scr.print("stack (255?): ")
c64scr.print_ub(X)
}
sub checkuw(uword uw) {
2019-07-09 02:09:29 +00:00
when uw {
12345 -> c64scr.print("12345")
12346 -> c64scr.print("12346")
2200 -> c64scr.print("2200")
2202 -> c64scr.print("2202")
12347 -> c64scr.print("12347")
else -> c64scr.print("not in table")
2019-07-09 02:09:29 +00:00
}
c64.CHROUT('\n')
}
2019-07-08 22:02:38 +00:00
sub check(ubyte a, ubyte y) {
when a+y {
10 -> {
c64scr.print("ten")
}
5, 6, 7 -> c64scr.print("five or six or seven")
30 -> c64scr.print("thirty")
2019-07-09 02:09:29 +00:00
31 -> c64scr.print("thirty1")
32 -> c64scr.print("thirty2")
33 -> c64scr.print("thirty3")
99 -> c64scr.print("nn")
55 -> {
; should be optimized away
}
56 -> {
; should be optimized away
}
else -> {
c64scr.print("not in table")
2019-07-08 22:02:38 +00:00
}
}
c64.CHROUT('\n')
2019-07-08 13:13:24 +00:00
}
}