cleanups.

also checked that value(12) < x < value(100) is indeed properly shortcircuited if x is 12 or less
This commit is contained in:
Irmen de Jong 2023-12-30 04:34:07 +01:00
parent 89cc7e5fa9
commit 1e1f444cab
3 changed files with 17 additions and 5 deletions

View File

@ -1056,7 +1056,6 @@ internal class AssignmentAsmGen(private val program: PtProgram,
when (expr.operator) {
"and" -> {
// short-circuit LEFT and RIGHT --> if LEFT then RIGHT else LEFT (== if !LEFT then LEFT else RIGHT)
println("SHORTCUT AND ${expr.position}") // TODO weg
assignExpressionToRegister(expr.left, RegisterOrPair.A, false)
asmgen.out(" beq $shortcutLabel")
assignExpressionToRegister(expr.right, RegisterOrPair.A, false)
@ -1064,7 +1063,6 @@ internal class AssignmentAsmGen(private val program: PtProgram,
}
"or" -> {
// short-circuit LEFT or RIGHT --> if LEFT then LEFT else RIGHT
println("SHORTCUT OR ${expr.position}") // TODO weg
assignExpressionToRegister(expr.left, RegisterOrPair.A, false)
asmgen.out(" bne $shortcutLabel")
assignExpressionToRegister(expr.right, RegisterOrPair.A, false)

View File

@ -798,7 +798,6 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
when (operator) {
"and" -> {
// short-circuit LEFT and RIGHT --> if LEFT then RIGHT else LEFT (== if !LEFT then LEFT else RIGHT)
println("SHORTCUT AND ${value.position}") // TODO weg
asmgen.out(" lda $name | beq $shortcutLabel")
asmgen.assignExpressionToRegister(value, RegisterOrPair.A, dt in SignedDatatypes)
asmgen.out("""
@ -809,7 +808,6 @@ $shortcutLabel:""")
}
"or" -> {
// short-circuit LEFT or RIGHT --> if LEFT then LEFT else RIGHT
println("SHORTCUT OR ${value.position}") // TODO weg
asmgen.out(" lda $name | bne $shortcutLabel")
asmgen.assignExpressionToRegister(value, RegisterOrPair.A, dt in SignedDatatypes)
asmgen.out("""

View File

@ -2,13 +2,29 @@
%zeropage dontuse
main {
sub start() {
ubyte @shared x = 10
if value(12) < x < value(100)
txt.print("gottem")
sub value(ubyte v) -> ubyte {
cx16.r0++
txt.print("value(): ")
txt.print_ub(v)
txt.nl()
return v
}
bigtest()
}
ubyte @shared a1 = 10
ubyte @shared a2 = 20
ubyte @shared x1 = 30
ubyte @shared x2 = 40
ubyte @shared zero = 0
sub start () {
sub bigtest () {
txt.print("1a:\n")
if calc_a1()<calc_x1() and calc_a2()<=calc_x2()
txt.print("* 1a and ok\n")