fix asm optimizer bug where it erroneously discarded rts with a label

This commit is contained in:
Irmen de Jong 2024-09-22 21:41:41 +02:00
parent 1d1d6b3d98
commit d3e4481112
3 changed files with 40 additions and 41 deletions

View File

@ -516,6 +516,8 @@ private fun optimizeJsrRtsAndOtherCombinations(linesByFour: Sequence<List<Indexe
val first = lines[0].value
val second = lines[1].value
val third = lines[2].value
if(!haslabel(second)) {
if ((" jsr" in first || "\tjsr" in first ) && (" rts" in second || "\trts" in second)) {
mods += Modification(lines[0].index, false, lines[0].value.replace("jsr", "jmp"))
mods += Modification(lines[1].index, true, null)
@ -543,7 +545,6 @@ private fun optimizeJsrRtsAndOtherCombinations(linesByFour: Sequence<List<Indexe
mods += Modification(lines[1].index, true, null)
}
if (!haslabel(second)) {
if ((" lda" in first || "\tlda" in first) && (" cmp #0" in second || "\tcmp #0" in second) ||
(" ldx" in first || "\tldx" in first) && (" cpx #0" in second || "\tcpx #0" in second) ||
(" ldy" in first || "\tldy" in first) && (" cpy #0" in second || "\tcpy #0" in second)

View File

@ -469,9 +469,6 @@ cx16 {
}
LIBRARY MODULE NAME: shared_cbm_textio_functions
------------------------------------------------
LIBRARY MODULE NAME: diskio
---------------------------
diskio {
@ -550,9 +547,6 @@ string {
}
LIBRARY MODULE NAME: shared_string_functions
--------------------------------------------
LIBRARY MODULE NAME: floats
---------------------------
floats {
@ -712,5 +706,3 @@ test_stack {
test ()
}

View File

@ -1,10 +1,16 @@
%import textio
%import floats
%zeropage basicsafe
main {
sub start() {
ubyte i
i++
ubyte i, j ; redefinition
i++
j++
float fl = 5.23
fl = floats.ceil(fl)
floats.print(fl)
txt.nl()
fl = 5.23
fl = floats.floor(fl)
floats.print(fl)
txt.nl()
}
}