inplace modification for memory now without translateExpression()

This commit is contained in:
Irmen de Jong 2020-11-18 23:23:06 +01:00
parent 2da28864e9
commit 72509eef44
2 changed files with 17 additions and 32 deletions

View File

@ -5,33 +5,6 @@
;
; 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)
; TODO get rid of this by not evaluating the adress onto the stack, but directly into AY or SCRATCH_W2
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)
; TODO get rid of this by not evaluating the adress onto the stack, but directly into AY or SCRATCH_W2
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,10 +182,15 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
}
}
else -> {
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")
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""")
val zp = CompilationTarget.instance.machine.zeropage
when {
valueLv != null -> inplaceModification_byte_litval_to_variable(zp.SCRATCH_B1.toHex(), DataType.UBYTE, operator, valueLv.toInt())
@ -197,7 +202,14 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
}
else -> inplaceModification_byte_value_to_variable(zp.SCRATCH_B1.toHex(), DataType.UBYTE, operator, value)
}
asmgen.out(" lda P8ZP_SCRATCH_B1 | jsr prog8_lib.write_byte_to_address_on_stack | inx")
asmgen.out("""
pla
sta P8ZP_SCRATCH_W2+1
pla
sta P8ZP_SCRATCH_W2
ldy #0
lda P8ZP_SCRATCH_B1
sta (P8ZP_SCRATCH_W2),y""")
}
}
}