diff --git a/compiler/res/prog8lib/string.p8 b/compiler/res/prog8lib/string.p8 index 7d853cef7..18fcf1069 100644 --- a/compiler/res/prog8lib/string.p8 +++ b/compiler/res/prog8lib/string.p8 @@ -176,7 +176,7 @@ _found sty P8ZP_SCRATCH_B1 }} } - asmsub compare(uword string1 @R0, uword string2 @AY) clobbers(Y) -> ubyte @A { + asmsub compare(uword string1 @R0, uword string2 @AY) clobbers(Y) -> byte @A { ; Compares two strings for sorting. ; Returns -1 (255), 0 or 1 depeding on wether string1 sorts before, equal or after string2. ; Note that you can also directly compare strings and string values with eachother using diff --git a/examples/cx16/assembler/assem.p8 b/examples/cx16/assembler/assem.p8 index 3d5e051c7..000b05dfe 100644 --- a/examples/cx16/assembler/assem.p8 +++ b/examples/cx16/assembler/assem.p8 @@ -62,7 +62,7 @@ textparse { } uword value = conv.any2uword(word_addrs[2]) - if word_addrs[0] == "*" { ; TODO does this string compare work? + if string.compare(word_addrs[0], "*")==0 { program_counter = value } else { set_symbol(word_addrs[0], value) diff --git a/examples/cx16/imageviewer/imageviewer.p8 b/examples/cx16/imageviewer/imageviewer.p8 index 8d4bfcd93..47c0eed36 100644 --- a/examples/cx16/imageviewer/imageviewer.p8 +++ b/examples/cx16/imageviewer/imageviewer.p8 @@ -55,7 +55,7 @@ main { ;txt.print(filenameptr) ;txt.chrout('\n') uword extension = filenameptr + rfind(filenameptr, '.') - if extension == ".iff" { ; TODO does this compare work? + if string.compare(extension, ".iff")==0 { ;txt.print("loading ") ;txt.print("iff\n") if iff_module.show_image(filenameptr) { @@ -71,7 +71,7 @@ main { load_error(filenameptr) } } - else if extension == ".pcx" { ; TODO works? + else if string.compare(extension, ".pcx")==0 { ;txt.print("loading ") ;txt.print("pcx\n") if pcx_module.show_image(filenameptr) { @@ -80,7 +80,7 @@ main { load_error(filenameptr) } } - else if extension == ".koa" { ; TODO works? + else if string.compare(extension,".koa")==0 { ;txt.print("loading ") ;txt.print("koala\n") if koala_module.show_image(filenameptr) { @@ -89,7 +89,7 @@ main { load_error(filenameptr) } } - else if extension == ".bmp" { ; TODO works? + else if string.compare(extension, ".bmp")==0 { ;txt.print("loading ") ;txt.print("bmp\n") if bmp_module.show_image(filenameptr) { diff --git a/examples/test.p8 b/examples/test.p8 index 117cacd20..db789ad09 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -8,88 +8,7 @@ main { ; TODO: error when a parameter has the same name as an existing module/block/subroutine: sub print_right(ubyte width, uword string) { - sub start() { - str s1 = "irmen" - str s2 = "what" - str s3 = "irmen2" - - s3[5] = 0 - - txt.print("length:\n") - txt.print_ub(len(s1)) - txt.chrout('\n') - txt.print_ub(string.length(s1)) - - txt.print("\n\ncopy:\n") - txt.print(s3) - txt.chrout('\n') - s3 = s2 - txt.print(s3) - txt.chrout('\n') - txt.print_ub(string.copy("new", s3)) - txt.print(s3) - - txt.print("\n\ncompare:\n") - txt.chrout('\n') - txt.print_ub(string.compare(s1, s2)) - txt.chrout('\n') - txt.print_ub(string.compare(s2, s1)) - txt.chrout('\n') - txt.print_ub(string.compare(s1, s3)) - txt.chrout('\n') - txt.chrout('\n') - txt.print_ub(s1==s2) - txt.chrout('\n') - txt.print_ub(s1s2) - txt.chrout('\n') - - txt.print("\n\nleft:") - string.left(s2,2,s3) - txt.print(s3) - txt.chrout('\n') - txt.print("\n\nright:\n") - txt.print(s2) - txt.chrout('\n') - string.right(s2,2,s3) - txt.print(s3) - txt.chrout('\n') - - txt.print("\n\nfind:\n") - txt.print(s1) - txt.chrout('\n') - uword found = string.find(s1, 'e') - txt.print_uwhex(found, 1) - if found - txt.print(found) - txt.chrout('\n') - found = string.find(s1, 'i') - txt.print_uwhex(found, 1) - if found - txt.print(found) - txt.chrout('\n') - found = string.find(s1, 'x') - txt.print_uwhex(found, 1) - if found - txt.print(found) - txt.chrout('\n') - - txt.print("\n\nslice:\n") - string.slice(s1, 0, 5, s2) - txt.print(s2) - txt.chrout('\n') - string.slice(s1, 1, 4, s2) - txt.print(s2) - txt.chrout('\n') - string.slice(s1, 2, 2, s2) - txt.print(s2) - txt.chrout('\n') - string.slice(s1, 3, 2, s2) - txt.print(s2) - txt.chrout('\n') - test_stack.test() }