diff --git a/compiler/src/prog8/compiler/target/c64/codegen/BuiltinFunctionsAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/BuiltinFunctionsAsmGen.kt index c03f2b270..da1ba36b0 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/BuiltinFunctionsAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/BuiltinFunctionsAsmGen.kt @@ -117,8 +117,8 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val when(func.name) { "memset" -> { // use the ROM function of the Cx16 - asmgen.assignExpressionToVariable(fcall.args[0], "cx16.r0", DataType.UWORD, scope) // TODO register R0 - asmgen.assignExpressionToVariable(fcall.args[1], "cx16.r1", DataType.UWORD, scope) // TODO register R1 + asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.R0) + asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.R1) asmgen.assignExpressionToRegister(fcall.args[2], RegisterOrPair.A) val sub = (fcall as FunctionCallStatement).definingSubroutine()!! asmgen.saveRegister(CpuRegister.X, false, sub) @@ -136,9 +136,9 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val } // use the ROM function of the Cx16 - asmgen.assignExpressionToVariable(fcall.args[0], "cx16.r0", DataType.UWORD, scope) // TODO register R0 - asmgen.assignExpressionToVariable(fcall.args[1], "cx16.r1", DataType.UWORD, scope) // TODO register R1 - asmgen.assignExpressionToVariable(fcall.args[2], "cx16.r2", DataType.UWORD, scope) // TODO register R2 + asmgen.assignExpressionToRegister(fcall.args[0], RegisterOrPair.R0) + asmgen.assignExpressionToRegister(fcall.args[1], RegisterOrPair.R1) + asmgen.assignExpressionToRegister(fcall.args[2], RegisterOrPair.R2) val sub = (fcall as FunctionCallStatement).definingSubroutine()!! asmgen.saveRegister(CpuRegister.X, false, sub) asmgen.out(" jsr cx16.memory_copy") diff --git a/compiler/src/prog8/compiler/target/c64/codegen/ExpressionsAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/ExpressionsAsmGen.kt index 971831496..fefe63352 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/ExpressionsAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/ExpressionsAsmGen.kt @@ -1381,7 +1381,15 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("cx16 register onto stack") + RegisterOrPair.R15 -> { + asmgen.out(""" + lda cx16.${reg.registerOrPair.toString().toLowerCase()} + sta P8ESTACK_LO,x + lda cx16.${reg.registerOrPair.toString().toLowerCase()}+1 + sta P8ESTACK_HI,x + dex + """) + } } } else if(reg.statusflag!=null) { diff --git a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AssignmentAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AssignmentAsmGen.kt index aff71241e..9d417b65f 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AssignmentAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AssignmentAsmGen.kt @@ -703,7 +703,15 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("assign stack byte to cx16 register") + RegisterOrPair.R15 -> { + asmgen.out(""" + inx + lda P8ESTACK_LO,x + sta cx16.${target.register.toString().toLowerCase()} + lda #0 + sta cx16.${target.register.toString().toLowerCase()}+1 + """) + } else -> throw AssemblyError("can't assign byte from stack to register pair XY") } } @@ -727,7 +735,15 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("assign stack word to cx16 register") + RegisterOrPair.R15 -> { + asmgen.out(""" + inx + lda P8ESTACK_LO,x + sta cx16.${target.register.toString().toLowerCase()} + lda P8ESTACK_HI,x + sta cx16.${target.register.toString().toLowerCase()}+1 + """) + } else -> throw AssemblyError("can't assign word to single byte register") } } @@ -1127,7 +1143,14 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("cx16 register assign byte var") + RegisterOrPair.R15 -> { + asmgen.out(""" + lda $sourceName + sta cx16.${target.register.toString().toLowerCase()} + lda #0 + sta cx16.${target.register.toString().toLowerCase()}+1 + """) + } } } TargetStorageKind.STACK -> { @@ -1299,7 +1322,13 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("cx16 register assign from register A") + RegisterOrPair.R15 -> { + asmgen.out(""" + sta cx16.${target.register.toString().toLowerCase()} + ldy #0 + sty cx16.${target.register.toString().toLowerCase()}+1 + """) + } } CpuRegister.X -> when(target.register!!) { RegisterOrPair.A -> { asmgen.out(" txa") } @@ -1324,7 +1353,13 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("cx16 register assign from register X") + RegisterOrPair.R15 -> { + asmgen.out(""" + stx cx16.${target.register.toString().toLowerCase()} + lda #0 + sta cx16.${target.register.toString().toLowerCase()}+1 + """) + } } CpuRegister.Y -> when(target.register!!) { RegisterOrPair.A -> { asmgen.out(" tya") } @@ -1349,7 +1384,12 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("cx16 register assign from register Y") + RegisterOrPair.R15 -> { + asmgen.out(""" + sty cx16.${target.register.toString().toLowerCase()} + lda #0 + sta cx16.${target.register.toString().toLowerCase()}+1 + """) } } } } @@ -1424,7 +1464,12 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("assign reg.pair to cx16 register") + RegisterOrPair.R15 -> { + asmgen.out(""" + sta cx16.${target.register.toString().toLowerCase()} + stx cx16.${target.register.toString().toLowerCase()}+1 + """) + } else -> throw AssemblyError("expected reg pair") } RegisterOrPair.AY -> when(target.register!!) { @@ -1446,7 +1491,12 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("assign reg.pair to cx16 register") + RegisterOrPair.R15 -> { + asmgen.out(""" + sta cx16.${target.register.toString().toLowerCase()} + sty cx16.${target.register.toString().toLowerCase()}+1 + """) + } else -> throw AssemblyError("expected reg pair") } RegisterOrPair.XY -> when(target.register!!) { @@ -1468,7 +1518,12 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("assign reg.pair to cx16 register") + RegisterOrPair.R15 -> { + asmgen.out(""" + stx cx16.${target.register.toString().toLowerCase()} + sty cx16.${target.register.toString().toLowerCase()}+1 + """) + } else -> throw AssemblyError("expected reg pair") } else -> throw AssemblyError("expected reg pair") @@ -1587,7 +1642,14 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("cx16 register assign constant byte") + RegisterOrPair.R15 -> { + asmgen.out(""" + lda #${byte.toHex()} + sta cx16.${target.register.toString().toLowerCase()} + lda #0 + sta cx16.${target.register.toString().toLowerCase()}+1 + """) + } } TargetStorageKind.STACK -> { asmgen.out(""" @@ -1772,7 +1834,14 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("cx16 register assign memory byte") + RegisterOrPair.R15 -> { + asmgen.out(""" + lda ${address.toHex()} + sta cx16.${target.register.toString().toLowerCase()} + lda #0 + sta cx16.${target.register.toString().toLowerCase()}+1 + """) + } } TargetStorageKind.STACK -> { asmgen.out(""" @@ -1819,7 +1888,13 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, - RegisterOrPair.R15 -> TODO("cx16 register assign memory byte") + RegisterOrPair.R15 -> { + asmgen.out(""" + sta cx16.${target.register.toString().toLowerCase()} + lda #0 + sta cx16.${target.register.toString().toLowerCase()}+1 + """) + } } } TargetStorageKind.STACK -> { diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 4f1e0fe43..c1d1d5a66 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,6 +2,7 @@ TODO ==== +- add target() function that returns 16=cx16, 64=C64 - Cx16 target: support full-screen 640x480 and 320x240 graphics? That requires our own custom graphics routines though to draw lines. - hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine) - make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_' diff --git a/examples/arithmetic/bitshift.p8 b/examples/arithmetic/bitshift.p8 index fd366e1b5..e536117c0 100644 --- a/examples/arithmetic/bitshift.p8 +++ b/examples/arithmetic/bitshift.p8 @@ -5,72 +5,72 @@ main { sub start() { - ubyte A + ubyte a txt.print("ubyte shift left\n") - A = shiftlb0() - txt.print_ubbin(A, true) + a = shiftlb0() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb1() - txt.print_ubbin(A, true) + a = shiftlb1() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb2() - txt.print_ubbin(A, true) + a = shiftlb2() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb3() - txt.print_ubbin(A, true) + a = shiftlb3() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb4() - txt.print_ubbin(A, true) + a = shiftlb4() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb5() - txt.print_ubbin(A, true) + a = shiftlb5() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb6() - txt.print_ubbin(A, true) + a = shiftlb6() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb7() - txt.print_ubbin(A, true) + a = shiftlb7() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb8() - txt.print_ubbin(A, true) + a = shiftlb8() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftlb9() - txt.print_ubbin(A, true) + a = shiftlb9() + txt.print_ubbin(a, true) c64.CHROUT('\n') txt.print("enter to continue:\n") void c64.CHRIN() txt.print("ubyte shift right\n") - A = shiftrb0() - txt.print_ubbin(A, true) + a = shiftrb0() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb1() - txt.print_ubbin(A, true) + a = shiftrb1() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb2() - txt.print_ubbin(A, true) + a = shiftrb2() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb3() - txt.print_ubbin(A, true) + a = shiftrb3() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb4() - txt.print_ubbin(A, true) + a = shiftrb4() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb5() - txt.print_ubbin(A, true) + a = shiftrb5() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb6() - txt.print_ubbin(A, true) + a = shiftrb6() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb7() - txt.print_ubbin(A, true) + a = shiftrb7() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb8() - txt.print_ubbin(A, true) + a = shiftrb8() + txt.print_ubbin(a, true) c64.CHROUT('\n') - A = shiftrb9() - txt.print_ubbin(A, true) + a = shiftrb9() + txt.print_ubbin(a, true) c64.CHROUT('\n') txt.print("enter to continue:\n") void c64.CHRIN() diff --git a/examples/arithmetic/postincrdecr.p8 b/examples/arithmetic/postincrdecr.p8 index 89ec4067d..562c27d2b 100644 --- a/examples/arithmetic/postincrdecr.p8 +++ b/examples/arithmetic/postincrdecr.p8 @@ -8,7 +8,7 @@ main { txt.plot(0,24) - ubyte Y + ubyte y ubyte ub=200 byte bb=-100 uword uw = 2000 @@ -33,9 +33,9 @@ main { flarr[1] ++ check_ub(ub, 201) - Y=100 - Y++ - check_ub(Y, 101) + y=100 + y++ + check_ub(y, 101) check_fl(fl, 1000.99) check_b(bb, -99) check_uw(uw, 2001) @@ -64,9 +64,9 @@ main { flarr[1] -- check_ub(ub, 200) - Y=100 - Y-- - check_ub(Y, 99) + y=100 + y-- + check_ub(y, 99) check_fl(fl, 999.99) check_b(bb, -100) check_uw(uw, 2000) diff --git a/examples/cx16/imageviewer/bmp_module.p8 b/examples/cx16/imageviewer/bmp_module.p8 index a76310252..d59e97c3f 100644 --- a/examples/cx16/imageviewer/bmp_module.p8 +++ b/examples/cx16/imageviewer/bmp_module.p8 @@ -72,12 +72,6 @@ bmp_module { height = graphics.HEIGHT-1 } - sub set_cursor(uword x, uword y) { - cx16.r0=offsetx+x - cx16.r1=offsety+y - cx16.FB_cursor_position() - } - sub decode_bitmap() { start_plot() uword bits_width = width * bpp @@ -87,7 +81,7 @@ bmp_module { uword y ubyte b for y in height-1 downto 0 { - set_cursor(0, y) + cx16.FB_cursor_position(offsetx, offsety+y) when bpp { 8 -> { for x in 0 to width-1 diff --git a/examples/cx16/imageviewer/iff_module.p8 b/examples/cx16/imageviewer/iff_module.p8 index da523372c..2cbf96101 100644 --- a/examples/cx16/imageviewer/iff_module.p8 +++ b/examples/cx16/imageviewer/iff_module.p8 @@ -139,12 +139,6 @@ iff_module { height = graphics.HEIGHT-1 } - sub set_cursor(uword x, uword y) { - cx16.r0=offsetx+x - cx16.r1=offsety+y - cx16.FB_cursor_position() - } - sub decode_raw() { start_plot() ubyte interlaced = (camg & $0004) != 0 @@ -153,7 +147,7 @@ iff_module { void diskio.f_read(scanline_data_ptr, interleave_stride) if interlaced void diskio.f_read(scanline_data_ptr, interleave_stride) - set_cursor(0, y) + cx16.FB_cursor_position(offsetx, offsety+y) planar_to_chunky_scanline() } } @@ -166,7 +160,7 @@ iff_module { decode_rle_scanline() if interlaced decode_rle_scanline() - set_cursor(0, y) + cx16.FB_cursor_position(offsetx, offsety+y) planar_to_chunky_scanline() } } diff --git a/examples/cx16/imageviewer/koala_module.p8 b/examples/cx16/imageviewer/koala_module.p8 index 1ba1645cf..40695c441 100644 --- a/examples/cx16/imageviewer/koala_module.p8 +++ b/examples/cx16/imageviewer/koala_module.p8 @@ -40,9 +40,7 @@ koala_module { for cy in 0 to 24*8 step 8 { for cx in 0 to 39 { for d in 0 to 7 { - cx16.r0 = cx as uword * 8 - cx16.r1 = cy as uword + d - cx16.FB_cursor_position() + cx16.FB_cursor_position(cx as uword * 8, cy as uword + d) get_8_pixels() cx16.FB_set_pixels(pixels, 8) } diff --git a/examples/cx16/imageviewer/pcx_module.p8 b/examples/cx16/imageviewer/pcx_module.p8 index 05926e5d1..f78fb63a3 100644 --- a/examples/cx16/imageviewer/pcx_module.p8 +++ b/examples/cx16/imageviewer/pcx_module.p8 @@ -83,23 +83,17 @@ bitmap { status = (not c64.READST()) or c64.READST()==64 } - sub set_cursor(uword x, uword y) { - cx16.r0=offsetx+x - cx16.r1=offsety+y - cx16.FB_cursor_position() - } - sub next_scanline() { px = 0 py++ y_ok = py < graphics.HEIGHT-1 - set_cursor(0, py) + cx16.FB_cursor_position(offsetx, offsety+py) status = (not c64.READST()) or c64.READST()==64 } sub do1bpp(uword width, uword height) -> ubyte { start_plot(width, height) - set_cursor(0, 0) + cx16.FB_cursor_position(offsetx, offsety) while py < height and status { ubyte b = c64.CHRIN() if b>>6==3 { @@ -124,7 +118,7 @@ bitmap { sub do4bpp(uword width, uword height) -> ubyte { start_plot(width, height) - set_cursor(0, 0) + cx16.FB_cursor_position(offsetx, offsety) while py < height and status { ubyte b = c64.CHRIN() if b>>6==3 { @@ -152,7 +146,7 @@ bitmap { sub do8bpp(uword width, uword height) -> ubyte { start_plot(width, height) - set_cursor(0, 0) + cx16.FB_cursor_position(offsetx, offsety) while py < height and status { ubyte b = c64.CHRIN() if b>>6==3 { diff --git a/examples/dirlist.p8 b/examples/dirlist.p8 index ba1bf390d..093b10529 100644 --- a/examples/dirlist.p8 +++ b/examples/dirlist.p8 @@ -10,8 +10,8 @@ main { void diskio.directory(8) txt.chrout('\n') - if diskio.lf_start_list(8, "cub", false) { - txt.print("\nfiles starting with 'cub':\n") + if diskio.lf_start_list(8, "nier", false) { + txt.print("\nfiles starting with 'nier':\n") while diskio.lf_next_entry() { txt.print(diskio.list_filename) txt.print(" ") @@ -23,8 +23,8 @@ main { txt.print("error\n") } - if diskio.lf_start_list(8, "gfx", true) { - txt.print("\nfiles ending with 'gfx':\n") + if diskio.lf_start_list(8, "pcx", true) { + txt.print("\nfiles ending with 'pcx':\n") while diskio.lf_next_entry() { txt.print(diskio.list_filename) txt.print(" ") diff --git a/examples/testarrays.p8 b/examples/testarrays.p8 index 9bcc6eceb..ac04af2ef 100644 --- a/examples/testarrays.p8 +++ b/examples/testarrays.p8 @@ -29,7 +29,7 @@ main { &uword[4] muwarray = $c000 &float[4] mflarray = $c000 - ubyte A + ubyte a byte bb ubyte ub word ww @@ -37,14 +37,14 @@ main { float fl ; read array - A=s1[2] + a=s1[2] ub=s1[2] bb=barray[2] ub=ubarray[2] ww=warray[2] uw=uwarray[2] fl=flarray[2] - A=ms1[2] + a=ms1[2] ub=ms1[2] bb=mbarray[2] ub=mubarray[2] @@ -52,29 +52,29 @@ main { uw=muwarray[2] fl=mflarray[2] - A=s1[A] - ub=s1[A] - bb=barray[A] - ub=ubarray[A] - ww=warray[A] - uw=uwarray[A] - fl=flarray[A] - A=ms1[A] - ub=ms1[A] - bb=mbarray[A] - ub=mubarray[A] - ww=mwarray[A] - uw=muwarray[A] - fl=mflarray[A] + a=s1[a] + ub=s1[a] + bb=barray[a] + ub=ubarray[a] + ww=warray[a] + uw=uwarray[a] + fl=flarray[a] + a=ms1[a] + ub=ms1[a] + bb=mbarray[a] + ub=mubarray[a] + ww=mwarray[a] + uw=muwarray[a] + fl=mflarray[a] - A=s1[bb] + a=s1[bb] ub=s1[bb] bb=barray[bb] ub=ubarray[bb] ww=warray[bb] uw=uwarray[bb] fl=flarray[bb] - A=ms1[bb] + a=ms1[bb] ub=ms1[bb] bb=mbarray[bb] ub=mubarray[bb] @@ -82,14 +82,14 @@ main { uw=muwarray[bb] fl=mflarray[bb] -; A=s1[bb*3] +; a=s1[bb*3] ; ub=s1[bb*3] ; bb=barray[bb*3] ; ub=ubarray[bb*3] ; ww=warray[bb*3] ; uw=uwarray[bb*3] ; fl=flarray[bb*3] -; A=ms1[bb*3] +; a=ms1[bb*3] ; ub=ms1[bb*3] ; bb=mbarray[bb*3] ; ub=mubarray[bb*3] @@ -100,14 +100,14 @@ main { ; write array barray[2]++ barray[2]-- - s1[2] = A + s1[2] = a s1[2] = ub barray[2] = bb ubarray[2] = ub warray[2] = ww uwarray[2] = uw flarray[2] = fl - ms1[2] = A + ms1[2] = a ms1[2] = ub mbarray[2]++ mbarray[2] = bb @@ -117,12 +117,12 @@ main { muwarray[2] = uw mflarray[2] = fl - s1[A] = ub - barray[A] = bb - ubarray[A] = ub - warray[A] = ww - uwarray[A] = uw - flarray[A] = fl + s1[a] = ub + barray[a] = bb + ubarray[a] = ub + warray[a] = ww + uwarray[a] = uw + flarray[a] = fl s1[bb] = ub barray[bb] = bb diff --git a/examples/testforloops.p8 b/examples/testforloops.p8 index 79fb0b48f..b32b18546 100644 --- a/examples/testforloops.p8 +++ b/examples/testforloops.p8 @@ -16,7 +16,7 @@ main { ubyte ub byte bb word total - ubyte A + ubyte a txt.plot(0,24) @@ -24,8 +24,8 @@ main { count = 0 total = 0 txt.print("a in string: ") - for A in "hello" { - aa=A + for a in "hello" { + aa=a count++ total += aa } @@ -37,8 +37,8 @@ main { count = 0 total = 0 txt.print("a in arrayliteral: ") - for A in [1,3,5,99] { - aa=A + for a in [1,3,5,99] { + aa=a count++ total += aa } @@ -50,8 +50,8 @@ main { count = 0 total = 0 txt.print("a in arrayvar: ") - for A in ubarr { - aa=A + for a in ubarr { + aa=a count++ total += aa } @@ -63,8 +63,8 @@ main { count = 0 total = 0 txt.print("a in range step 1: ") - for A in 10 to 20 { - aa=A + for a in 10 to 20 { + aa=a count++ total += aa } @@ -76,8 +76,8 @@ main { count = 0 total = 0 txt.print("a in range step -1: ") - for A in 20 downto 10 { - aa=A + for a in 20 downto 10 { + aa=a count++ total += aa } @@ -89,8 +89,8 @@ main { count = 0 total = 0 txt.print("a in range step 3: ") - for A in 10 to 21 step 3 { - aa=A + for a in 10 to 21 step 3 { + aa=a count++ total += aa } @@ -102,8 +102,8 @@ main { count = 0 total = 0 txt.print("a in rangeincl step 3: ") - for A in 10 to 22 step 3 { - aa=A + for a in 10 to 22 step 3 { + aa=a count++ total += aa } @@ -115,8 +115,8 @@ main { count = 0 total = 0 txt.print("a in range step -3: ") - for A in 24 to 10 step -3 { - aa=A + for a in 24 to 10 step -3 { + aa=a count++ total += aa } @@ -128,8 +128,8 @@ main { count = 0 total = 0 txt.print("a in rangeincl step -3: ") - for A in 24 to 9 step -3 { - aa=A + for a in 24 to 9 step -3 { + aa=a count++ total += aa } @@ -142,8 +142,8 @@ main { total = 0 endub1=101 txt.print("a in ncrange step 1: ") - for A in 95 to endub1 step 1 { - aa=A + for a in 95 to endub1 step 1 { + aa=a count++ total += aa } @@ -156,8 +156,8 @@ main { total = 0 endub1=101 txt.print("a in ncrange step -1: ") - for A in endub1 downto 95 { - aa=A + for a in endub1 downto 95 { + aa=a count++ total += aa } @@ -170,8 +170,8 @@ main { total = 0 endub1=105 txt.print("a in ncrange step 3: ") - for A in 95 to endub1 step 3 { - aa=A + for a in 95 to endub1 step 3 { + aa=a count++ total += aa } @@ -184,8 +184,8 @@ main { total = 0 endub1=105 txt.print("a in ncrange step -3: ") - for A in endub1 to 95 step -3 { - aa=A + for a in endub1 to 95 step -3 { + aa=a count++ total += aa } @@ -198,8 +198,8 @@ main { total = 0 endub1=107 txt.print("a in ncrangeinc step 3: ") - for A in 95 to endub1 step 3 { - aa=A + for a in 95 to endub1 step 3 { + aa=a count++ total += aa } @@ -212,8 +212,8 @@ main { total = 0 endub1=107 txt.print("a in ncrangeinc step -3: ") - for A in endub1 to 95 step -3 { - aa=A + for a in endub1 to 95 step -3 { + aa=a count++ total += aa } diff --git a/examples/textelite.p8 b/examples/textelite.p8 index 71a79494b..3c660e829 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -100,7 +100,7 @@ trader { txt.print("ok\n") } else { txt.print("\ni/o error: ") - diskio.status(8) + txt.print(diskio.status(8)) txt.chrout('\n') return } @@ -128,7 +128,7 @@ trader { txt.print("ok\n") } else { txt.print("\ni/o error: ") - diskio.status(8) + txt.print(diskio.status(8)) txt.chrout('\n') } } @@ -927,7 +927,6 @@ planet { util { sub prefix_matches(uword prefixptr, uword stringptr) -> ubyte { - ubyte ix=0 repeat { ubyte pc = @(prefixptr) ubyte sc = @(stringptr)