diff --git a/lib/compile/bcc.ml b/lib/compile/bcc.ml index ea242aa..3cd03b4 100644 --- a/lib/compile/bcc.ml +++ b/lib/compile/bcc.ml @@ -14,7 +14,7 @@ let compile modl = let bb = ref ep in let emit is = Code.add_ins !bb is in - let emit_mov l r = if r <> Code.Reg l then emit (MOV (l, r)) in + let emit_mov lhs rhs = if rhs <> Code.Reg lhs then emit (MOV (lhs, rhs)) in let rec compile_exp env = function | Ast.Literal Nil -> Code.Cst_nil @@ -33,9 +33,9 @@ let compile modl = | Ast.Binop (op, lhs, rhs) -> let ret = !sp in let lhs = compile_exp env lhs in - let rhs = compile_exp env rhs in - sp := ret + 1; emit_mov ret lhs; + sp := ret + 1; + let rhs = compile_exp env rhs in (match op with | Ast.Add -> emit (ADD (ret, rhs)) | Ast.Sub -> emit (SUB (ret, rhs))