fix fallthrough problem with 'when'. Fix too greedy asm optimization that caused conditional jumps to fail sometimes because the condition value wasn't loaded.

This commit is contained in:
Irmen de Jong 2020-09-26 00:22:55 +02:00
parent 225bfc4164
commit b976360248
4 changed files with 209 additions and 197 deletions

View File

@ -1017,6 +1017,7 @@ $counterVar .byte 0""")
} }
} }
} }
out(" jmp $endLabel")
for(choiceBlock in choiceBlocks) { for(choiceBlock in choiceBlocks) {
out(choiceBlock.first) out(choiceBlock.first)
translate(choiceBlock.second) translate(choiceBlock.second)

View File

@ -31,13 +31,6 @@ fun optimizeAssembly(lines: MutableList<String>): Int {
numberOfOptimizations++ numberOfOptimizations++
} }
mods = optimizeStoreLoadSame(linesByFour)
if(mods.isNotEmpty()) {
apply(mods, lines)
linesByFour = getLinesBy(lines, 4)
numberOfOptimizations++
}
mods= optimizeJsrRts(linesByFour) mods= optimizeJsrRts(linesByFour)
if(mods.isNotEmpty()) { if(mods.isNotEmpty()) {
apply(mods, lines) apply(mods, lines)

View File

@ -7,8 +7,6 @@
; staged speed increase ; staged speed increase
; some simple sound effects ; some simple sound effects
; TODO fix auto dropping of blocks (first fix testarrays)
%target c64 %target c64
%import syslib %import syslib
%import textio %import textio

View File

@ -7,198 +7,218 @@
main { main {
sub keypress(ubyte key) {
txt.print("keypress:")
txt.print_ub(key)
txt.chrout('=')
when key {
157, ',' -> txt.chrout('a')
29, '/' -> txt.chrout('b')
17, '.' -> txt.chrout('c')
145, ' ' -> txt.chrout('d')
}
txt.chrout('\n')
}
sub start() { sub start() {
byte bb= -22 repeat {
ubyte ubb = 22 ubyte key=c64.GETIN()
word ww= -2222 if key
uword uww = 2222 keypress(key)
float ff = -1.2345
repeat(25)
txt.chrout('\n')
if bb < -1 {
txt.print("1 ok\n")
} else {
txt.print("1 fail\n")
} }
if bb < -99 { ; byte bb= -22
txt.print("2 fail\n") ; ubyte ubb = 22
} else { ; word ww= -2222
txt.print("2 ok\n") ; uword uww = 2222
} ; float ff = -1.2345
;
if bb<0 { ; repeat(25)
txt.print("2b ok\n") ; txt.chrout('\n')
} else { ;
txt.print("2b fail\n") ; if bb < -1 {
} ; txt.print("1 ok\n")
; } else {
if ww < -1 { ; txt.print("1 fail\n")
txt.print("3 ok\n") ; }
} else { ;
txt.print("3 fail\n") ; if bb < -99 {
} ; txt.print("2 fail\n")
; } else {
if ww < -9999 { ; txt.print("2 ok\n")
txt.print("4 fail\n") ; }
} else { ;
txt.print("4 ok\n") ; if bb<0 {
} ; txt.print("2b ok\n")
; } else {
if ww < 0 { ; txt.print("2b fail\n")
txt.print("4b ok\n") ; }
} else { ;
txt.print("4b fail\n") ; if ww < -1 {
} ; txt.print("3 ok\n")
; } else {
if ff < -1.0 { ; txt.print("3 fail\n")
txt.print("4c ok\n") ; }
} else { ;
txt.print("4c fail\n") ; if ww < -9999 {
} ; txt.print("4 fail\n")
; } else {
if ff < -9999.9 { ; txt.print("4 ok\n")
txt.print("4d fail\n") ; }
} else { ;
txt.print("4d ok\n") ; if ww < 0 {
} ; txt.print("4b ok\n")
; } else {
if ff < 0.0 { ; txt.print("4b fail\n")
txt.print("4e ok\n") ; }
} else { ;
txt.print("4e fail\n") ; if ff < -1.0 {
} ; txt.print("4c ok\n")
; } else {
if ubb < 100 { ; txt.print("4c fail\n")
txt.print("4f ok\n") ; }
} else { ;
txt.print("4f fail\n") ; if ff < -9999.9 {
} ; txt.print("4d fail\n")
; } else {
if ubb < 2 { ; txt.print("4d ok\n")
txt.print("4g fail\n") ; }
} else { ;
txt.print("4g ok\n") ; if ff < 0.0 {
} ; txt.print("4e ok\n")
; } else {
if ubb<0 { ; txt.print("4e fail\n")
txt.print("4h fail\n") ; }
} else { ;
txt.print("4h ok\n") ; if ubb < 100 {
} ; txt.print("4f ok\n")
; } else {
if uww < 10000 { ; txt.print("4f fail\n")
txt.print("4i ok\n") ; }
} else { ;
txt.print("4i fail\n") ; if ubb < 2 {
} ; txt.print("4g fail\n")
; } else {
if uww < 2 { ; txt.print("4g ok\n")
txt.print("4j fail\n") ; }
} else { ;
txt.print("4j ok\n") ; if ubb<0 {
} ; txt.print("4h fail\n")
; } else {
if uww < 0 { ; txt.print("4h ok\n")
txt.print("4k fail\n") ; }
} else { ;
txt.print("4k ok\n") ; if uww < 10000 {
} ; txt.print("4i ok\n")
; } else {
; txt.print("4i fail\n")
; }
if bb > -99 { ;
txt.print("5 ok\n") ; if uww < 2 {
} else { ; txt.print("4j fail\n")
txt.print("5 fail\n") ; } else {
} ; txt.print("4j ok\n")
; }
if bb > -1 { ;
txt.print("6 fail\n") ; if uww < 0 {
} else { ; txt.print("4k fail\n")
txt.print("6 ok\n") ; } else {
} ; txt.print("4k ok\n")
; }
if bb > 0 { ;
txt.print("6b fail\n") ;
} else { ;
txt.print("6b ok\n") ; if bb > -99 {
} ; txt.print("5 ok\n")
; } else {
if ww > -9999 { ; txt.print("5 fail\n")
txt.print("7 ok\n") ; }
} else { ;
txt.print("7 fail\n") ; if bb > -1 {
} ; txt.print("6 fail\n")
; } else {
if ww > -1 { ; txt.print("6 ok\n")
txt.print("8 fail\n") ; }
} else { ;
txt.print("8 ok\n") ; if bb > 0 {
} ; txt.print("6b fail\n")
; } else {
if ww>0 { ; txt.print("6b ok\n")
txt.print("8b fail\n") ; }
} else { ;
txt.print("8b ok\n") ; if ww > -9999 {
} ; txt.print("7 ok\n")
; } else {
if ff > -1.0 { ; txt.print("7 fail\n")
txt.print("8c fail\n") ; }
} else { ;
txt.print("8c ok\n") ; if ww > -1 {
} ; txt.print("8 fail\n")
; } else {
if ff > -9999.9 { ; txt.print("8 ok\n")
txt.print("8d ok\n") ; }
} else { ;
txt.print("8d fail\n") ; if ww>0 {
} ; txt.print("8b fail\n")
; } else {
if ff > 0.0 { ; txt.print("8b ok\n")
txt.print("8e fail\n") ; }
} else { ;
txt.print("8e ok\n") ; if ff > -1.0 {
} ; txt.print("8c fail\n")
; } else {
if ubb > 5 { ; txt.print("8c ok\n")
txt.print("8f ok\n") ; }
} else { ;
txt.print("8f fail\n") ; if ff > -9999.9 {
} ; txt.print("8d ok\n")
; } else {
if ubb > 250 { ; txt.print("8d fail\n")
txt.print("8g fail\n") ; }
} else { ;
txt.print("8g ok\n") ; if ff > 0.0 {
} ; txt.print("8e fail\n")
; } else {
if ubb > 0 { ; txt.print("8e ok\n")
txt.print("8h ok\n") ; }
} else { ;
txt.print("8h fail\n") ; if ubb > 5 {
} ; txt.print("8f ok\n")
; } else {
if uww > 5 { ; txt.print("8f fail\n")
txt.print("8i ok\n") ; }
} else { ;
txt.print("8i fail\n") ; if ubb > 250 {
} ; txt.print("8g fail\n")
; } else {
if uww > 9999 { ; txt.print("8g ok\n")
txt.print("8j fail\n") ; }
} else { ;
txt.print("8j ok\n") ; if ubb > 0 {
} ; txt.print("8h ok\n")
; } else {
if uww>0 { ; txt.print("8h fail\n")
txt.print("8b ok\n") ; }
} else { ;
txt.print("8b fail\n") ; if uww > 5 {
} ; txt.print("8i ok\n")
; } else {
; txt.print("8i fail\n")
; }
;
; if uww > 9999 {
; txt.print("8j fail\n")
; } else {
; txt.print("8j ok\n")
; }
;
; if uww>0 {
; txt.print("8b ok\n")
; } else {
; txt.print("8b fail\n")
; }
; @($c000) *= 99 ; TODO implement ; @($c000) *= 99 ; TODO implement