diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-08 22:25:55 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-08 22:34:00 -0400 |
commit | a88da5465b89aaf308eeef6db02b8ee2970b5cd5 (patch) | |
tree | f80f195d4ce1f32439b6c2618fc19d42a36996d3 | |
parent | 3aedb2dba1343172ebca96ffd181c96cdaddd698 (diff) |
Add assignment code generation
-rw-r--r-- | gen_code.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -4,6 +4,9 @@ #include <string.h> #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); } |