diff --git a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt index 0167fbc22..7550640ca 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt @@ -1368,36 +1368,41 @@ $label nop""") if(write) { when(ptrAndIndex.second) { is NumericLiteralValue, is IdentifierReference -> { - assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) if(pointervar!=null && isZpVar(pointervar)) { + assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) out(" sta (${asmSymbolName(pointervar)}),y") } else { // copy the pointer var to zp first assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null) + assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) out(" sta (P8ZP_SCRATCH_W2),y") } } else -> { // same as above but we need to save the A register - out(" pha") - assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) - out(" pla") if(pointervar!=null && isZpVar(pointervar)) { + out(" pha") + assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) + out(" pla") out(" 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") } } } } else { - assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) if(pointervar!=null && isZpVar(pointervar)) { + assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) out(" lda (${asmSymbolName(pointervar)}),y") } else { // copy the pointer var to zp first assignExpressionToVariable(ptrAndIndex.first, asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, null) + assignExpressionToRegister(ptrAndIndex.second, RegisterOrPair.Y) out(" lda (P8ZP_SCRATCH_W2),y") } } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index c6f5ba376..814debcce 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,7 +2,6 @@ TODO ==== -- [pointer-index-optimize branch] fix imageviewer color cycling on champagne and weathermap iff images - the others are ok. The REVERSE cycling is broken. - allow uwordpointer[index] syntax -> transform into @(uwordpointer+index) allow index to be >255! - add any2(), all2(), max2(), min2(), reverse2(), sum2(), sort2() that take (array, startindex, length) arguments - optimize for loop iterations better to allow proper inx, cpx #value, bne loop instructions (like repeat loop)