mirror of
https://github.com/irmen/prog8.git
synced 2025-01-10 20:30:23 +00:00
word arrays for sorting should be @nosplit
This commit is contained in:
parent
78c71bbf0e
commit
c84cc8f8c9
@ -120,10 +120,9 @@ _done
|
||||
uword @zp temp = peekw(values+i*$0002)
|
||||
ubyte @zp j = i
|
||||
ubyte @zp k = j-gap
|
||||
repeat {
|
||||
while j>=gap {
|
||||
uword @zp v = peekw(values+k*2)
|
||||
if v <= temp break
|
||||
if j < gap break
|
||||
pokew(values+j*2, v)
|
||||
j = k
|
||||
k -= gap
|
||||
@ -144,11 +143,10 @@ _done
|
||||
cx16.r1 = peekw(pointers+i*$0002)
|
||||
ubyte @zp j = i
|
||||
ubyte @zp k = j-gap
|
||||
repeat {
|
||||
while j>=gap {
|
||||
cx16.r0 = peekw(pointers+k*2)
|
||||
void call(comparefunc)
|
||||
if_cs break
|
||||
if j < gap break
|
||||
pokew(pointers+j*2, cx16.r0)
|
||||
j = k
|
||||
k -= gap
|
||||
|
@ -833,10 +833,10 @@ sorting (experimental)
|
||||
----------------------
|
||||
Various sorting routines (gnome sort and shell sort variants) for byte, word and string arrays.
|
||||
API is experimental and may change or disappear in a future version.
|
||||
**NOTE:** all word arrays are assumed to be @nosplit, words and pointers need to be consecutive in memory.
|
||||
**NOTE:** all word and str arrays have to be @nosplit! Words and pointers need to be consecutive in memory for now.
|
||||
**NOTE:** sorting is done in ascending order.
|
||||
Read the `sorting source code <https://github.com/irmen/prog8/tree/master/compiler/res/prog8lib/sorting.p8>`_
|
||||
to see what's in there.
|
||||
to see what's in there. Also check out the `sortingbech` example.
|
||||
|
||||
|
||||
sprites (cx16 only)
|
||||
|
@ -9,8 +9,8 @@
|
||||
main {
|
||||
ubyte[50] array1
|
||||
ubyte[50] array2
|
||||
uword[50] warray1
|
||||
uword[50] warray2
|
||||
uword[50] @nosplit warray1
|
||||
uword[50] @nosplit warray2
|
||||
str[22] @nosplit fruits
|
||||
str[] @nosplit original_fruits = ["mango", "banana", "cranberry", "zucchini", "blackberry", "orange", "dragonfruit", "cherry",
|
||||
"kiwifruit", "lychee", "peach", "apricot", "tomato", "avocado", "nectarine", "pear",
|
||||
|
Loading…
x
Reference in New Issue
Block a user