diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ForLoopsAsmGen.kt b/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ForLoopsAsmGen.kt index e52b36839..fbeeab42a 100644 --- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ForLoopsAsmGen.kt +++ b/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ForLoopsAsmGen.kt @@ -289,17 +289,15 @@ $loopLabel sty $indexVar bne $loopLabel beq $endLabel""") } - if(length>=16 && asmgen.zeropage.hasByteAvailable()) { - // TODO don't check for byte avail first, just use allocate and handle error - // allocate index var on ZP + if(length>=16) { + // allocate index var on ZP if possible val result = asmgen.zeropage.allocate(indexVar, DataType.UBYTE, null, stmt.position, asmgen.errors) result.fold( success = { zpAddr-> asmgen.out("""$indexVar = $zpAddr ; auto zp UBYTE""") }, - failure = { /*TODO regular allocation */} + failure = { asmgen.out("$indexVar .byte 0") } ) } else { - asmgen.out(""" -$indexVar .byte 0""") + asmgen.out("$indexVar .byte 0") } asmgen.out(endLabel) } @@ -332,17 +330,15 @@ $loopLabel sty $indexVar bne $loopLabel beq $endLabel""") } - if(length>=16 && asmgen.zeropage.hasByteAvailable()) { - // TODO don't check for byte avail first, just use allocate and handle error - // allocate index var on ZP + if(length>=16) { + // allocate index var on ZP if possible val result = asmgen.zeropage.allocate(indexVar, DataType.UBYTE, null, stmt.position, asmgen.errors) result.fold( success = { zpAddr-> asmgen.out("""$indexVar = $zpAddr ; auto zp UBYTE""") }, - failure = { /*TODO regular allocation */} + failure = { asmgen.out("$indexVar .byte 0") } ) } else { - asmgen.out(""" -$indexVar .byte 0""") + asmgen.out("$indexVar .byte 0") } asmgen.out(endLabel) } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 9cc830f85..0587886fb 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -4,7 +4,6 @@ TODO For next compiler release (7.7) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - fix array and string initialization in zeropage -- fix ForloopAsmGen zp allocation handling - check all examples if they still run correctly (c64 + cx16) - document check: arrays and strings can also be placed in zeropage (but almost never should, due to size!) - document @requirezp and add to syntax def files and IDEA