2019-08-17 23:39:48 +00:00
|
|
|
%import c64lib
|
|
|
|
%import c64utils
|
|
|
|
%zeropage basicsafe
|
|
|
|
|
|
|
|
main {
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
|
|
|
|
ubyte[] uba = [10,0,2,8,5,4,3,9]
|
|
|
|
uword[] uwa = [1000,0,200,8000,50,40000,3,900]
|
|
|
|
byte[] ba = [-10,0,-2,8,5,4,-3,9,-99]
|
|
|
|
word[] wa = [-1000,0,-200,8000,50,31111,3,-900]
|
|
|
|
|
|
|
|
c64scr.print("original\n")
|
|
|
|
print_arrays()
|
|
|
|
|
|
|
|
sort(uba)
|
|
|
|
sort(uwa)
|
|
|
|
sort(ba)
|
|
|
|
sort(wa)
|
|
|
|
|
|
|
|
c64scr.print("sorted\n")
|
|
|
|
print_arrays()
|
|
|
|
|
|
|
|
reverse(uba)
|
|
|
|
reverse(uwa)
|
|
|
|
reverse(ba)
|
|
|
|
reverse(wa)
|
|
|
|
|
|
|
|
c64scr.print("reversed\n")
|
|
|
|
print_arrays()
|
2020-03-12 23:27:33 +00:00
|
|
|
|
2020-03-12 23:50:50 +00:00
|
|
|
check_eval_stack()
|
2019-08-17 23:39:48 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
sub print_arrays() {
|
2019-08-18 01:16:23 +00:00
|
|
|
ubyte ub
|
|
|
|
uword uw
|
|
|
|
byte bb
|
|
|
|
word ww
|
|
|
|
for ub in uba {
|
2019-08-17 23:39:48 +00:00
|
|
|
c64scr.print_ub(ub)
|
|
|
|
c64.CHROUT(',')
|
|
|
|
}
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
|
2019-08-18 01:16:23 +00:00
|
|
|
for uw in uwa {
|
2019-08-17 23:39:48 +00:00
|
|
|
c64scr.print_uw(uw)
|
|
|
|
c64.CHROUT(',')
|
|
|
|
}
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
|
2019-08-18 01:16:23 +00:00
|
|
|
for bb in ba {
|
2019-08-17 23:39:48 +00:00
|
|
|
c64scr.print_b(bb)
|
|
|
|
c64.CHROUT(',')
|
|
|
|
}
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
|
2019-08-18 01:16:23 +00:00
|
|
|
for ww in wa {
|
2019-08-17 23:39:48 +00:00
|
|
|
c64scr.print_w(ww)
|
|
|
|
c64.CHROUT(',')
|
|
|
|
}
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
}
|
|
|
|
}
|
2020-03-12 23:27:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
sub check_eval_stack() {
|
|
|
|
if X!=255 {
|
|
|
|
c64scr.print("stack x=")
|
|
|
|
c64scr.print_ub(X)
|
|
|
|
c64scr.print(" error!\n")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-17 23:39:48 +00:00
|
|
|
}
|