improved ForloopAsmGen loopvar zp allocation

This commit is contained in:
Irmen de Jong 2022-01-15 13:57:14 +01:00
parent a798fe72d3
commit 0f0f40bff3
2 changed files with 8 additions and 13 deletions

View File

@ -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)
}

View File

@ -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