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 first = lines[0].value
val second = lines[1].value val second = lines[1].value
val third = lines[2].value val third = lines[2].value
if(!haslabel(second)) {
if ((" jsr" in first || "\tjsr" in first ) && (" rts" in second || "\trts" in 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[0].index, false, lines[0].value.replace("jsr", "jmp"))
mods += Modification(lines[1].index, true, null) 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) 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) || 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) || (" 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) (" 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 LIBRARY MODULE NAME: diskio
--------------------------- ---------------------------
diskio { diskio {
@ -550,9 +547,6 @@ string {
} }
LIBRARY MODULE NAME: shared_string_functions
--------------------------------------------
LIBRARY MODULE NAME: floats LIBRARY MODULE NAME: floats
--------------------------- ---------------------------
floats { floats {
@ -712,5 +706,3 @@ test_stack {
test () test ()
} }

View File

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