From 4fad63bffa5d91f566737090e3476cddbf59ed3b Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 9 Oct 2019 00:48:44 -0400 Subject: Fix changes mov to movq --- gen_code.c | 14 +++++++------- node.c | 2 ++ scope.c | 1 - tree.h | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gen_code.c b/gen_code.c index 3efb5bf..b89b622 100644 --- a/gen_code.c +++ b/gen_code.c @@ -66,14 +66,14 @@ ptree *t; if ((!t->r) && (!t->l) && t->label == 0){ switch (t->type) { case ID: - fprintf(stdout, "mov\t%d(%%rbp), %s\n", + fprintf(stdout, "movq\t%d(%%rbp), %s\n", - t->attr.nval->offset * OFFSET_SIZE, *reg_ptr); break; case INUM: - fprintf(stdout, "mov\t$%d, %s\n",t->attr.ival, *reg_ptr); + fprintf(stdout, "movq\t$%d, %s\n",t->attr.ival, *reg_ptr); break; default: - fprintf(stdout, "mov OTHER"); + fprintf(stdout, "movq OTHER"); } } /*case 0 @@ -82,13 +82,13 @@ ptree *t; /*TODO check if correct*/ switch (t->type) { case ID: - fprintf(stdout, "mov\t%s, %s\n",t->attr.nval->name, *reg_ptr); + fprintf(stdout, "movq\t%s, %s\n",t->attr.nval->name, *reg_ptr); break; case INUM: - fprintf(stdout, "mov\t$%d, %s\n",t->attr.ival, *reg_ptr); + fprintf(stdout, "movq\t$%d, %s\n",t->attr.ival, *reg_ptr); break; default: - fprintf(stdout, "mov OTHER"); + fprintf(stdout, "movq OTHER"); } } /*case 1 @@ -149,7 +149,7 @@ ptree *t; gen_label(t->r); print_tree(t); GEN_EXPR(t->r); - fprintf(stdout, "mov %s, %d(%%rbp)\n", *reg_ptr, + fprintf(stdout, "movq %s, %d(%%rbp)\n", *reg_ptr, - t->l->attr.nval->offset * OFFSET_SIZE); } else { yyerror(FLOAT_ERROR); diff --git a/node.c b/node.c index bde1ed6..da51455 100644 --- a/node.c +++ b/node.c @@ -20,6 +20,8 @@ char *str; p->func_info = NULL; p->array_info = NULL; + p->offset = 0; + return p; } diff --git a/scope.c b/scope.c index 47e5943..c2b3c8e 100644 --- a/scope.c +++ b/scope.c @@ -21,7 +21,6 @@ scope* mkscope() p->prev = NULL; p->ret_var= NULL; - p->offset = 2; return p; } diff --git a/tree.h b/tree.h index cd8a947..a90947d 100644 --- a/tree.h +++ b/tree.h @@ -29,6 +29,7 @@ ptree* mkinum(int); ptree* mkrnum(float); ptree* mkop(int, int, ptree*, ptree*); +int update_offsets(ptree*, int); void update_type_info(ptree*, ptree*); void set_ret_type(ptree*); -- cgit v1.1