mirror of
https://github.com/irmen/prog8.git
synced 2024-09-09 02:54:28 +00:00
fix wrong code for inplace modification of a pointervariable's memory value
This commit is contained in:
parent
3d743a1ba1
commit
e342311bef
@ -364,6 +364,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
|
|
||||||
private fun inplaceModification_byte_value_to_pointer(pointervar: IdentifierReference, operator: String, value: Expression) {
|
private fun inplaceModification_byte_value_to_pointer(pointervar: IdentifierReference, operator: String, value: Expression) {
|
||||||
asmgen.assignExpressionToVariable(value, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
|
asmgen.assignExpressionToVariable(value, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
|
||||||
|
val sourceName = asmgen.loadByteFromPointerIntoA(pointervar)
|
||||||
when (operator) {
|
when (operator) {
|
||||||
// note: ** (power) operator requires floats.
|
// note: ** (power) operator requires floats.
|
||||||
"+" -> asmgen.out(" clc | adc P8ZP_SCRATCH_B1")
|
"+" -> 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")
|
"^", "xor" -> asmgen.out(" eor P8ZP_SCRATCH_B1")
|
||||||
else -> throw AssemblyError("invalid operator for in-place modification $operator")
|
else -> throw AssemblyError("invalid operator for in-place modification $operator")
|
||||||
}
|
}
|
||||||
// TODO THIS IS WRONG:????
|
|
||||||
val sourceName = asmgen.loadByteFromPointerIntoA(pointervar)
|
|
||||||
asmgen.storeAIntoZpPointerVar(sourceName)
|
asmgen.storeAIntoZpPointerVar(sourceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ TODO
|
|||||||
|
|
||||||
For next compiler release (7.5)
|
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)
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,11 +3,27 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
word llw = 300
|
ubyte @zp xx
|
||||||
cx16.r0s = 9 * 2 * 10 * llw
|
for xx in 0 to 10 {
|
||||||
cx16.r1s = llw * 9 * 2 * 10
|
txt.print_ub(xx)
|
||||||
cx16.r3s = llw / 30 / 3
|
txt.spc()
|
||||||
cx16.r4s = llw / 2 * 10
|
}
|
||||||
cx16.r5s = llw * 90 / 5 ; not optimized because of loss of integer division precision
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user