From f4b60f43cf636d48f8857676b072371f1575a5b2 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 6 Jan 2018 21:38:40 +0100 Subject: Working compiler --- compiler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler.c') diff --git a/compiler.c b/compiler.c index c6adf6a..b0297f9 100644 --- a/compiler.c +++ b/compiler.c @@ -278,7 +278,7 @@ static void compile_node(struct ir *ir, struct symtab *symtab, struct node *node symtab = symtab_sub(symtab); for (int i = 0; i < numparams; i++) { struct symbol *parsym = symbol_make_var(strdup(sym->params[i].name), sym->params[i].type); - parsym->ref = ref_mem(REG_BP, -2 - i, REFREL_ZERO); + parsym->ref = ref_mem(REG_BP, 2 + i, REFREL_ZERO); symtab_insert(symtab, parsym); } @@ -368,6 +368,7 @@ static void compile_data_setup(struct ir *ir, struct symtab *symtab, struct node ir_append(ir, irins_make_jcc(afterlbl, CCNZ)); compile_data_setup_node(ir, symtab, root); + ir_append(ir, irins_make_01(INS_MOV, flag, ref_imm(1))); ir_append(ir, irins_make_name(INS_LBL, afterlbl)); ir_append(ir, irins_make_name(INS_CALL, "main")); -- cgit v1.2.3-54-g00ecf