From 8bb3b3be20a6c7f373853e8780be5657d7fd808d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 9 Oct 2020 22:30:21 +0200 Subject: [PATCH] fix repeat loop for variables when var == 0 --- compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt index c57b6afe5..e622c6410 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt @@ -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)