From b734dc44fd12a3cf7173c2667bd805e63dac4f38 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 26 Mar 2020 01:13:20 +0100 Subject: [PATCH] fix invalid assembly for @(address)++/-- --- .../target/c64/codegen/PostIncrDecrAsmGen.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/compiler/src/prog8/compiler/target/c64/codegen/PostIncrDecrAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/PostIncrDecrAsmGen.kt index 1e6fd0b66..c17f47584 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/PostIncrDecrAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/PostIncrDecrAsmGen.kt @@ -66,7 +66,20 @@ internal class PostIncrDecrAsmGen(private val program: Program, private val asmg } is IdentifierReference -> { val what = asmgen.asmIdentifierName(addressExpr) - asmgen.out(if(incr) " inc $what" else " dec $what") + asmgen.out(""" + ldy $what + sty ${C64Zeropage.SCRATCH_W1} + ldy $what+1 + sty ${C64Zeropage.SCRATCH_W1 + 1} + ldy #0 + lda (${C64Zeropage.SCRATCH_W1}),y +""") + if(incr) + asmgen.out(" clc | adc #1") + else + asmgen.out(" sec | sbc #1") + + asmgen.out(" sta (${C64Zeropage.SCRATCH_W1}),y") } else -> throw AssemblyError("weird target type $targetMemory") }