mirror of
https://github.com/irmen/prog8.git
synced 2024-10-19 07:23:56 +00:00
inplace modification for memory now without translateExpression()
This commit is contained in:
parent
2da28864e9
commit
72509eef44
@ -5,33 +5,6 @@
|
|||||||
;
|
;
|
||||||
; indent format: TABS, size=8
|
; 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
|
neg_b .proc
|
||||||
lda #0
|
lda #0
|
||||||
sec
|
sec
|
||||||
|
@ -182,10 +182,15 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
if(asmgen.options.slowCodegenWarnings)
|
asmgen.assignExpressionToVariable(memory.addressExpression, asmgen.asmVariableName("P8ZP_SCRATCH_W2"), DataType.UWORD, target.scope)
|
||||||
println("warning: slow stack evaluation used (1): ${memory.addressExpression::class.simpleName} at ${memory.addressExpression.position}") // TODO optimize...
|
asmgen.out("""
|
||||||
asmgen.translateExpression(memory.addressExpression) // TODO directly into P8ZP_SCRATCH_W2
|
lda P8ZP_SCRATCH_W2
|
||||||
asmgen.out(" jsr prog8_lib.read_byte_from_address_on_stack | sta P8ZP_SCRATCH_B1")
|
pha
|
||||||
|
lda P8ZP_SCRATCH_W2+1
|
||||||
|
pha
|
||||||
|
ldy #0
|
||||||
|
lda (P8ZP_SCRATCH_W2),y
|
||||||
|
sta P8ZP_SCRATCH_B1""")
|
||||||
val zp = CompilationTarget.instance.machine.zeropage
|
val zp = CompilationTarget.instance.machine.zeropage
|
||||||
when {
|
when {
|
||||||
valueLv != null -> inplaceModification_byte_litval_to_variable(zp.SCRATCH_B1.toHex(), DataType.UBYTE, operator, valueLv.toInt())
|
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)
|
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""")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user