aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-10-09 00:48:44 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-10-09 00:58:37 -0400
commit4fad63bffa5d91f566737090e3476cddbf59ed3b (patch)
tree9b3a08b67af0f1deba694518c683d4bb9c89b663
parentabae0a645f4272a1052b939ee47f2a07d90b2002 (diff)
Fix changes mov to movq
-rw-r--r--gen_code.c14
-rw-r--r--node.c2
-rw-r--r--scope.c1
-rw-r--r--tree.h1
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*);