diff --git a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt index de6316718..20948e277 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt @@ -1412,13 +1412,15 @@ $label nop""") when(ptrAndIndex.second) { is NumericLiteralValue, is IdentifierReference -> { if(pointervar!=null && isZpVar(pointervar)) { + out(" pha") assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) - out(" sta (${asmSymbolName(pointervar)}),y") + out(" pla | sta (${asmSymbolName(pointervar)}),y") } else { // copy the pointer var to zp first + out(" pha") assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null) assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) - out(" sta (P8ZP_SCRATCH_W2),y") + out(" pla | sta (P8ZP_SCRATCH_W2),y") } } else -> { @@ -1426,15 +1428,13 @@ $label nop""") if(pointervar!=null && isZpVar(pointervar)) { out(" pha") assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) - out(" pla") - out(" sta (${asmSymbolName(pointervar)}),y") + out(" pla | sta (${asmSymbolName(pointervar)}),y") } else { // copy the pointer var to zp first assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null) out(" pha") assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) - out(" pla") - out(" sta (P8ZP_SCRATCH_W2),y") + out(" pla | sta (P8ZP_SCRATCH_W2),y") } } } diff --git a/examples/test.p8 b/examples/test.p8 index 81d0a1a3d..52697a5e8 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,21 +1,19 @@ %import textio -%zeropage basicsafe +%zeropage dontuse %option no_sysinit main { ; $1F9C0 - $1F9FF PSG registers + sub init(uword addr, ubyte length) { + @(addr+length) = $ea + } + sub start() { - ubyte xx = '?' - when xx { - 'a' -> txt.print("a\n") - 'b' -> txt.print("b\n") - '?' -> { - } - else -> txt.print("else\n") - } + init($4000, 0) + txt.print_uwhex(@($4000), true) ; uword freq = 1181 ; cx16.vpoke(1, $f9c0, lsb(freq))