diff --git a/compiler/src/prog8/astvm/AstVm.kt b/compiler/src/prog8/astvm/AstVm.kt index 8016a2bf0..081b0cf6f 100644 --- a/compiler/src/prog8/astvm/AstVm.kt +++ b/compiler/src/prog8/astvm/AstVm.kt @@ -285,9 +285,6 @@ class AstVm(val program: Program) { } } } - is BuiltinFunctionStatementPlaceholder -> { - TODO("builtinfun $stmt") - } is Return -> throw LoopControlReturn(stmt.values.map { evaluate(it, evalCtx) }) is Continue -> throw LoopControlContinue() is Break -> throw LoopControlBreak() @@ -339,7 +336,15 @@ class AstVm(val program: Program) { executeAnonymousScope(stmt.elsepart) } is BranchStatement -> { - TODO("branch $stmt") + when(stmt.condition) { + BranchCondition.CS -> if(statusflags.carry) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart) + BranchCondition.CC -> if(!statusflags.carry) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart) + BranchCondition.EQ, BranchCondition.Z -> if(statusflags.zero) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart) + BranchCondition.NE, BranchCondition.NZ -> if(statusflags.zero) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart) + BranchCondition.MI, BranchCondition.NEG -> if(statusflags.negative) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart) + BranchCondition.PL, BranchCondition.POS -> if(statusflags.negative) executeAnonymousScope(stmt.truepart) else executeAnonymousScope(stmt.elsepart) + BranchCondition.VS, BranchCondition.VC -> TODO("overflow status") + } } is ForLoop -> { val iterable = evaluate(stmt.iterable, evalCtx) diff --git a/examples/test.p8 b/examples/test.p8 index 9013dd23f..7e1ae1684 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -18,6 +18,21 @@ word w1 = 1111 word w2 = 2222 + sum(arr2) + + if_cc goto start + if_cs goto start + if_eq goto start + if_mi goto start + if_ne goto start + if_neg goto start + if_nz goto start + if_pl goto start + if_pos goto start + if_vc goto start + if_vs goto start + if_z goto start + m1 = 0 mw1 = 65535