mirror of
https://github.com/irmen/prog8.git
synced 2025-01-13 10:29:52 +00:00
more ifexpression codegen tweaks
This commit is contained in:
parent
84d9040b57
commit
97b8cb748d
@ -417,6 +417,33 @@ internal class IfElseAsmGen(private val program: PtProgram,
|
||||
}
|
||||
}
|
||||
|
||||
if(constValue!=0) {
|
||||
// TODO reuse more code from regular if statements. Need a shared routine like isWordExprEqualNumber() ?
|
||||
when(condition.operator) {
|
||||
"==" -> {
|
||||
// if w==number
|
||||
asmgen.assignExpressionToRegister(condition.left, RegisterOrPair.AY, signed)
|
||||
asmgen.out("""
|
||||
cmp #<$constValue
|
||||
bne $falseLabel
|
||||
cpy #>$constValue
|
||||
bne $falseLabel""")
|
||||
return
|
||||
}
|
||||
"!=" -> {
|
||||
// if w!=number
|
||||
asmgen.assignExpressionToRegister(condition.left, RegisterOrPair.AY, signed)
|
||||
asmgen.out("""
|
||||
cmp #<$constValue
|
||||
bne +
|
||||
cpy #>$constValue
|
||||
beq $falseLabel
|
||||
+""")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO don't store condition as expression result but just use the flags, like a normal PtIfElse translation does
|
||||
assignConditionValueToRegisterAndTest(condition)
|
||||
asmgen.out(" beq $falseLabel")
|
||||
|
@ -1,4 +1,5 @@
|
||||
; Routines to load and save "BMX" files (commander X16 bitmap format) Version 1.
|
||||
; Bitmap data is loaded directly into VRAM without intermediary buffering.
|
||||
; Only uncompressed images are supported for now.
|
||||
; BMX Specification: https://cx16forum.com/forum/viewtopic.php?t=6945
|
||||
|
||||
|
@ -5,21 +5,19 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
byte @shared ww = -99
|
||||
ww++
|
||||
|
||||
if ww&1 ==0
|
||||
txt.print("x ")
|
||||
|
||||
if ww&64 ==0
|
||||
txt.print("a ")
|
||||
|
||||
if ww&128!=0
|
||||
txt.print("neg ")
|
||||
|
||||
txt.print_ub(if ww & 64==0 111 else 222)
|
||||
txt.spc()
|
||||
txt.print_ub(if ww & 128!=0 111 else 222)
|
||||
word @shared ww = 11111
|
||||
txt.print_ub(if ww==11111 111 else 222)
|
||||
txt.spc()
|
||||
txt.print_ub(if ww!=11111 111 else 222)
|
||||
txt.nl()
|
||||
|
||||
if ww==11111
|
||||
txt.print("one\n")
|
||||
else
|
||||
txt.print("two\n")
|
||||
if ww!=11111
|
||||
txt.print("one\n")
|
||||
else
|
||||
txt.print("two\n")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user