diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-09 00:48:44 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-09 00:58:37 -0400 |
commit | 4fad63bffa5d91f566737090e3476cddbf59ed3b (patch) | |
tree | 9b3a08b67af0f1deba694518c683d4bb9c89b663 | |
parent | abae0a645f4272a1052b939ee47f2a07d90b2002 (diff) |
Fix changes mov to movq
-rw-r--r-- | gen_code.c | 14 | ||||
-rw-r--r-- | node.c | 2 | ||||
-rw-r--r-- | scope.c | 1 | ||||
-rw-r--r-- | tree.h | 1 |
4 files changed, 10 insertions, 8 deletions
@@ -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); @@ -20,6 +20,8 @@ char *str; p->func_info = NULL; p->array_info = NULL; + p->offset = 0; + return p; } @@ -21,7 +21,6 @@ scope* mkscope() p->prev = NULL; p->ret_var= NULL; - p->offset = 2; return p; } @@ -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*); |