mirror of
https://github.com/irmen/prog8.git
synced 2024-11-20 03:32:05 +00:00
fix cpu stack corruption in array assignment codegen
This commit is contained in:
parent
0a83b51e00
commit
a9f5dc036c
@ -93,8 +93,7 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
SourceStorageKind.ARRAY -> inplaceModification_word_value_to_variable(target.asmVarname, target.datatype, operator, value.array!!)
|
SourceStorageKind.ARRAY -> inplaceModification_word_value_to_variable(target.asmVarname, target.datatype, operator, value.array!!)
|
||||||
SourceStorageKind.EXPRESSION -> {
|
SourceStorageKind.EXPRESSION -> {
|
||||||
if(value.expression is PtTypeCast) {
|
if(value.expression is PtTypeCast) {
|
||||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator))
|
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) return
|
||||||
return
|
|
||||||
inplaceModification_word_value_to_variable(target.asmVarname, target.datatype, operator, value.expression)
|
inplaceModification_word_value_to_variable(target.asmVarname, target.datatype, operator, value.expression)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -271,8 +270,10 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
SourceStorageKind.ARRAY -> inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.array!!)
|
SourceStorageKind.ARRAY -> inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.array!!)
|
||||||
SourceStorageKind.EXPRESSION -> {
|
SourceStorageKind.EXPRESSION -> {
|
||||||
if(value.expression is PtTypeCast) {
|
if(value.expression is PtTypeCast) {
|
||||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator))
|
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) {
|
||||||
|
asmgen.restoreRegisterLocal(CpuRegister.Y)
|
||||||
return
|
return
|
||||||
|
}
|
||||||
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression)
|
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression)
|
||||||
} else {
|
} else {
|
||||||
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression!!)
|
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression!!)
|
||||||
@ -301,8 +302,10 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
SourceStorageKind.ARRAY -> inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.array!!)
|
SourceStorageKind.ARRAY -> inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.array!!)
|
||||||
SourceStorageKind.EXPRESSION -> {
|
SourceStorageKind.EXPRESSION -> {
|
||||||
if(value.expression is PtTypeCast) {
|
if(value.expression is PtTypeCast) {
|
||||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator))
|
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) {
|
||||||
|
asmgen.restoreRegisterLocal(CpuRegister.Y)
|
||||||
return
|
return
|
||||||
|
}
|
||||||
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression)
|
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression)
|
||||||
} else {
|
} else {
|
||||||
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression!!)
|
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression!!)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
|
- fix double code gen with tryInplaceModifyWithRemovedRedundantCast() ? word birdX[j] += testbyte
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,39 +1,13 @@
|
|||||||
main
|
%zeropage basicsafe
|
||||||
{
|
|
||||||
sub start()
|
|
||||||
{
|
|
||||||
ubyte variable=55
|
|
||||||
when variable
|
|
||||||
{
|
|
||||||
33 -> cx16.r0++
|
|
||||||
else -> cx16.r1++
|
|
||||||
}
|
|
||||||
|
|
||||||
if variable {
|
main {
|
||||||
cx16.r0++
|
|
||||||
} else {
|
|
||||||
cx16.r1++
|
|
||||||
}
|
|
||||||
|
|
||||||
if variable { cx16.r0++ }
|
sub start() {
|
||||||
else { cx16.r1++ }
|
word[4] birdX
|
||||||
|
byte testbyte = 0
|
||||||
if variable
|
ubyte j = 0
|
||||||
{
|
repeat {
|
||||||
cx16.r0++
|
birdX[j] += testbyte
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
cx16.r1++
|
|
||||||
}
|
|
||||||
|
|
||||||
other.othersub()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
other {
|
|
||||||
sub othersub() {
|
|
||||||
cx16.r0++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user