diff --git a/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt b/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt index c51f332b9..1564a233d 100644 --- a/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt +++ b/codeGeneration/src/prog8/compiler/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt @@ -364,6 +364,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, private fun inplaceModification_byte_value_to_pointer(pointervar: IdentifierReference, operator: String, value: Expression) { asmgen.assignExpressionToVariable(value, "P8ZP_SCRATCH_B1", DataType.UBYTE, null) + val sourceName = asmgen.loadByteFromPointerIntoA(pointervar) when (operator) { // note: ** (power) operator requires floats. "+" -> asmgen.out(" clc | adc P8ZP_SCRATCH_B1") @@ -394,8 +395,6 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, "^", "xor" -> asmgen.out(" eor P8ZP_SCRATCH_B1") else -> throw AssemblyError("invalid operator for in-place modification $operator") } - // TODO THIS IS WRONG:???? - val sourceName = asmgen.loadByteFromPointerIntoA(pointervar) asmgen.storeAIntoZpPointerVar(sourceName) } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 8f90aede8..5dbf3feb2 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,7 +3,7 @@ TODO For next compiler release (7.5) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -check correctness of inplaceModification_byte_value_to_pointer() +- allow cx16.rX as loop variable in forloops (now requires unqualified identifiername) ... diff --git a/examples/test.p8 b/examples/test.p8 index a47227daf..bca37af23 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -3,11 +3,27 @@ main { sub start() { - word llw = 300 - cx16.r0s = 9 * 2 * 10 * llw - cx16.r1s = llw * 9 * 2 * 10 - cx16.r3s = llw / 30 / 3 - cx16.r4s = llw / 2 * 10 - cx16.r5s = llw * 90 / 5 ; not optimized because of loss of integer division precision + ubyte @zp xx + for xx in 0 to 10 { + txt.print_ub(xx) + txt.spc() + } + txt.nl() + + for cx16.r0L in 0 to 10 { + txt.print_ub(cx16.r0L) + txt.spc() + } + txt.nl() + + for main.derp.xx in 0 to 10 { + txt.print_ub(main.derp.xx) + txt.spc() + } + txt.nl() + } + + sub derp() { + ubyte xx } }