From a88da5465b89aaf308eeef6db02b8ee2970b5cd5 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Tue, 8 Oct 2019 22:25:55 -0400 Subject: Add assignment code generation --- gen_code.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gen_code.c b/gen_code.c index e967929..55bc05a 100644 --- a/gen_code.c +++ b/gen_code.c @@ -4,6 +4,9 @@ #include #include "gen_code.h" #include "pc.h" +#include "scope.h" + +scope *cur_scope; #define REG_SWAP {\ char *tmp_reg_swap = *reg_ptr;\ @@ -139,8 +142,11 @@ ptree *t; switch (t->type){ case ASSIGNOP: if (t->l->ret_type == INT) { + gen_label(t->r); + print_tree(t); GEN_EXPR(t->r); - fprintf(stdout, "mov %s, ADDR\n", *reg_ptr); + fprintf(stdout, "mov %s, %d(%%rbp)\n", *reg_ptr, + - t->l->attr.nval->offset * OFFSET_SIZE); } else { fprintf(stderr, "ASSIGN (REAL) %s\n", t->l->attr.nval->name); } -- cgit v1.1