rollback failed optimization of memory expressions (code size got too large)

This commit is contained in:
Irmen de Jong 2020-11-21 19:09:02 +01:00
parent 7def8ff2cd
commit 8be234973c
3 changed files with 31 additions and 18 deletions

View File

@ -5,6 +5,32 @@
;
; indent format: TABS, size=8
read_byte_from_address_on_stack .proc
; -- read the byte from the memory address on the top of the stack, return in A (stack remains unchanged)
lda P8ESTACK_LO+1,x
ldy P8ESTACK_HI+1,x
sta P8ZP_SCRATCH_W2
sty P8ZP_SCRATCH_W2+1
ldy #0
lda (P8ZP_SCRATCH_W2),y
rts
.pend
write_byte_to_address_on_stack .proc
; -- write the byte in A to the memory address on the top of the stack (stack remains unchanged)
ldy P8ESTACK_LO+1,x
sty P8ZP_SCRATCH_W2
ldy P8ESTACK_HI+1,x
sty P8ZP_SCRATCH_W2+1
ldy #0
sta (P8ZP_SCRATCH_W2),y
rts
.pend
neg_b .proc
lda #0
sec

View File

@ -182,15 +182,10 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
}
}
else -> {
asmgen.assignExpressionToVariable(memory.addressExpression, asmgen.asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, target.scope)
asmgen.out("""
lda P8ZP_SCRATCH_W2
pha
lda P8ZP_SCRATCH_W2+1
pha
ldy #0
lda (P8ZP_SCRATCH_W2),y
sta P8ZP_SCRATCH_B1""")
if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (1): ${memory.addressExpression::class.simpleName} at ${memory.addressExpression.position}") // TODO optimize...
asmgen.translateExpression(memory.addressExpression) // TODO directly into P8ZP_SCRATCH_W2
asmgen.out(" jsr prog8_lib.read_byte_from_address_on_stack | sta P8ZP_SCRATCH_B1")
val zp = CompilationTarget.instance.machine.zeropage
when {
valueLv != null -> inplaceModification_byte_litval_to_variable(zp.SCRATCH_B1.toHex(), DataType.UBYTE, operator, valueLv.toInt())
@ -202,14 +197,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
}
else -> inplaceModification_byte_value_to_variable(zp.SCRATCH_B1.toHex(), DataType.UBYTE, operator, value)
}
asmgen.out("""
pla
sta P8ZP_SCRATCH_W2+1
pla
sta P8ZP_SCRATCH_W2
ldy #0
lda P8ZP_SCRATCH_B1
sta (P8ZP_SCRATCH_W2),y""")
asmgen.out(" lda P8ZP_SCRATCH_B1 | jsr prog8_lib.write_byte_to_address_on_stack | inx")
}
}
}

View File

@ -5,7 +5,6 @@
%option no_sysinit
; Create a custom character set on the C64.
; TODO why is this one significantly larger than with older compiler?
main {