2020-09-20 21:49:36 +00:00
|
|
|
%import textio
|
2020-11-22 17:17:43 +00:00
|
|
|
%import test_stack
|
2019-08-17 23:39:48 +00:00
|
|
|
%zeropage basicsafe
|
|
|
|
|
2020-09-20 21:49:36 +00:00
|
|
|
; Note: this program is compatible with C64 and CX16.
|
|
|
|
|
2019-08-17 23:39:48 +00:00
|
|
|
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]
|
|
|
|
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("original\n")
|
2019-08-17 23:39:48 +00:00
|
|
|
print_arrays()
|
|
|
|
|
|
|
|
sort(uba)
|
|
|
|
sort(uwa)
|
|
|
|
sort(ba)
|
|
|
|
sort(wa)
|
|
|
|
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("sorted\n")
|
2019-08-17 23:39:48 +00:00
|
|
|
print_arrays()
|
|
|
|
|
|
|
|
reverse(uba)
|
|
|
|
reverse(uwa)
|
|
|
|
reverse(ba)
|
|
|
|
reverse(wa)
|
|
|
|
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("reversed\n")
|
2019-08-17 23:39:48 +00:00
|
|
|
print_arrays()
|
2020-03-12 23:27:33 +00:00
|
|
|
|
2020-11-22 17:17:43 +00:00
|
|
|
;test_stack.test()
|
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 {
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print_ub(ub)
|
2020-09-20 21:49:36 +00:00
|
|
|
txt.chrout(',')
|
2019-08-17 23:39:48 +00:00
|
|
|
}
|
2020-09-20 21:49:36 +00:00
|
|
|
txt.chrout('\n')
|
2019-08-17 23:39:48 +00:00
|
|
|
|
2019-08-18 01:16:23 +00:00
|
|
|
for uw in uwa {
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print_uw(uw)
|
2020-09-20 21:49:36 +00:00
|
|
|
txt.chrout(',')
|
2019-08-17 23:39:48 +00:00
|
|
|
}
|
2020-09-20 21:49:36 +00:00
|
|
|
txt.chrout('\n')
|
2019-08-17 23:39:48 +00:00
|
|
|
|
2019-08-18 01:16:23 +00:00
|
|
|
for bb in ba {
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print_b(bb)
|
2020-09-20 21:49:36 +00:00
|
|
|
txt.chrout(',')
|
2019-08-17 23:39:48 +00:00
|
|
|
}
|
2020-09-20 21:49:36 +00:00
|
|
|
txt.chrout('\n')
|
2019-08-17 23:39:48 +00:00
|
|
|
|
2019-08-18 01:16:23 +00:00
|
|
|
for ww in wa {
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print_w(ww)
|
2020-09-20 21:49:36 +00:00
|
|
|
txt.chrout(',')
|
2019-08-17 23:39:48 +00:00
|
|
|
}
|
2020-09-20 21:49:36 +00:00
|
|
|
txt.chrout('\n')
|
|
|
|
txt.chrout('\n')
|
2019-08-17 23:39:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|