fix repeat loop for variables when var == 0

This commit is contained in:
Irmen de Jong 2020-10-09 22:30:21 +02:00
parent 85e3c2c5a2
commit 8bb3b3be20

View File

@ -960,7 +960,11 @@ _prog8_regsaveY .byte 0""") // TODO only generate these bytes if the
// note: A/Y must have been loaded with the number of iterations already!
val counterVar = makeLabel("repeatcounter")
out("""
sta $counterVar
bne +
cpy #0
bne +
beq $endLabel
+ sta $counterVar
sty $counterVar+1
$repeatLabel lda $counterVar
bne +
@ -989,6 +993,7 @@ $counterVar .word 0""")
// note: A must have been loaded with the number of iterations already!
val counterVar = makeLabel("repeatcounter")
out("""
beq $endLabel
sta $counterVar
$repeatLabel""")
translate(body)