From 2da28864e9e935a38b44922bec7b2515c87713d8 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 18 Nov 2020 23:13:07 +0100 Subject: [PATCH] inplace not and invert for memory now without translateExpression() --- .../assignment/AugmentableAssignmentAsmGen.kt | 20 ++++++++----------- examples/test.p8 | 14 ++++++------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt index 426cea304..dcf2e5213 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/assignment/AugmentableAssignmentAsmGen.kt @@ -1696,16 +1696,14 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, asmgen.out(" sta (P8ZP_SCRATCH_W1),y") } else -> { - if(asmgen.options.slowCodegenWarnings) - println("warning: slow stack evaluation used (6): ${mem.addressExpression::class.simpleName} at ${mem.addressExpression.position}") // TODO - asmgen.translateExpression(mem.addressExpression) // TODO directly into P8ZP_SCRATCH_W2 + asmgen.assignExpressionToVariable(mem.addressExpression, asmgen.asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, target.scope) asmgen.out(""" - jsr prog8_lib.read_byte_from_address_on_stack + ldy #0 + lda (P8ZP_SCRATCH_W2),y beq + lda #1 + eor #1 - jsr prog8_lib.write_byte_to_address_on_stack - inx""") + sta (P8ZP_SCRATCH_W2),y""") } } } @@ -1766,14 +1764,12 @@ internal class AugmentableAssignmentAsmGen(private val program: Program, asmgen.out(" sta (P8ZP_SCRATCH_W1),y") } else -> { - if(asmgen.options.slowCodegenWarnings) - println("warning: slow stack evaluation used (7): ${memory.addressExpression::class.simpleName} at ${memory.addressExpression.position}") // TODO - asmgen.translateExpression(memory.addressExpression) // TODO directly into P8ZP_SCRATCH_W2 + asmgen.assignExpressionToVariable(memory.addressExpression, asmgen.asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, target.scope) asmgen.out(""" - jsr prog8_lib.read_byte_from_address_on_stack + ldy #0 + lda (P8ZP_SCRATCH_W2),y eor #255 - jsr prog8_lib.write_byte_to_address_on_stack - inx""") + sta (P8ZP_SCRATCH_W2),y""") } } } diff --git a/examples/test.p8 b/examples/test.p8 index 23261306e..f99d9d303 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -6,16 +6,14 @@ main { sub start() { - ubyte ub = 2 - ubyte ub2 = 8 - uword uw = 5 + ubyte ub = 1 + ubyte ub2 = %11000011 - ub2 <<= (ub-1) - txt.print_ub(ub2) - txt.chrout('\n') + @($c001) = %1 - ub2 >>= (ub-1) - txt.print_ub(ub2) + @($c000+ub) += @($c000+ub) + ub2 = @($c000+ub) + txt.print_ubbin(ub2, 1) txt.chrout('\n') testX()