mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +00:00
cleanups.
also checked that value(12) < x < value(100) is indeed properly shortcircuited if x is 12 or less
This commit is contained in:
parent
89cc7e5fa9
commit
1e1f444cab
@ -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)
|
||||
|
@ -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("""
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user