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.EXPRESSION -> {
|
||||
if(value.expression is PtTypeCast) {
|
||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator))
|
||||
return
|
||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) return
|
||||
inplaceModification_word_value_to_variable(target.asmVarname, target.datatype, operator, value.expression)
|
||||
}
|
||||
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.EXPRESSION -> {
|
||||
if(value.expression is PtTypeCast) {
|
||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator))
|
||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) {
|
||||
asmgen.restoreRegisterLocal(CpuRegister.Y)
|
||||
return
|
||||
}
|
||||
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression)
|
||||
} else {
|
||||
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.EXPRESSION -> {
|
||||
if(value.expression is PtTypeCast) {
|
||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator))
|
||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) {
|
||||
asmgen.restoreRegisterLocal(CpuRegister.Y)
|
||||
return
|
||||
}
|
||||
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression)
|
||||
} else {
|
||||
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression!!)
|
||||
|
@ -1,6 +1,8 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- fix double code gen with tryInplaceModifyWithRemovedRedundantCast() ? word birdX[j] += testbyte
|
||||
|
||||
...
|
||||
|
||||
|
||||
|
@ -1,39 +1,13 @@
|
||||
main
|
||||
{
|
||||
sub start()
|
||||
{
|
||||
ubyte variable=55
|
||||
when variable
|
||||
{
|
||||
33 -> cx16.r0++
|
||||
else -> cx16.r1++
|
||||
}
|
||||
%zeropage basicsafe
|
||||
|
||||
if variable {
|
||||
cx16.r0++
|
||||
} else {
|
||||
cx16.r1++
|
||||
}
|
||||
main {
|
||||
|
||||
if variable { cx16.r0++ }
|
||||
else { cx16.r1++ }
|
||||
|
||||
if variable
|
||||
{
|
||||
cx16.r0++
|
||||
sub start() {
|
||||
word[4] birdX
|
||||
byte testbyte = 0
|
||||
ubyte j = 0
|
||||
repeat {
|
||||
birdX[j] += testbyte
|
||||
}
|
||||
else
|
||||
{
|
||||
cx16.r1++
|
||||
}
|
||||
|
||||
other.othersub()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
other {
|
||||
sub othersub() {
|
||||
cx16.r0++
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user