diff --git a/compiler/src/prog8/compiler/target/c64/codegen/PostIncrDecrAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/PostIncrDecrAsmGen.kt index 915bc62a1..ddabe0d0b 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/PostIncrDecrAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/PostIncrDecrAsmGen.kt @@ -7,6 +7,8 @@ import prog8.ast.expressions.NumericLiteralValue import prog8.ast.statements.PostIncrDecr import prog8.compiler.AssemblyError import prog8.compiler.target.c64.C64MachineDefinition.C64Zeropage +import prog8.compiler.target.c64.C64MachineDefinition.ESTACK_HI_HEX +import prog8.compiler.target.c64.C64MachineDefinition.ESTACK_LO_HEX import prog8.compiler.toHex @@ -53,7 +55,20 @@ internal class PostIncrDecrAsmGen(private val program: Program, private val asmg else asmgen.out("+\tdec ${'$'}ffff\t; modified") } - else -> TODO("asmgen postincrdecr on memory expression") + else -> { + asmgen.translateExpression(addressExpr) + asmgen.out(""" + inx + lda $ESTACK_LO_HEX,x + sta (+) + 1 + lda $ESTACK_HI_HEX,x + sta (+) + 2 + """) + if(incr) + asmgen.out("+\tinc ${'$'}ffff\t; modified") + else + asmgen.out("+\tdec ${'$'}ffff\t; modified") + } } } targetArrayIdx!=null -> { diff --git a/examples/test.p8 b/examples/test.p8 index f44b7efc6..631dfd690 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -8,20 +8,17 @@ main { sub start() { ;@($d020) += @($d020) ; TODO fix compiler hang - ;@($c000+A) ++ ; TODO implement this - uword addr = $c000 - @(addr) = $f1 - c64scr.print_ubhex(@(addr), true) + ubyte A = 10 + @($c00a) = $4a + @($c000+A) ++ ; TODO implement this + + c64scr.print_ubhex(@($c00a), true) c64.CHROUT('\n') - @(addr) = - @(addr) - c64scr.print_ubhex(@(addr), true) - c64.CHROUT('\n') - @(addr) = - @(addr) - c64scr.print_ubhex(@(addr), true) + @($c000+A) -- ; TODO implement this + + c64scr.print_ubhex(@($c00a), true) c64.CHROUT('\n') - ;@($c000) = ! @($c000) - ;@($c000) = ~ @($c000) } }