aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gen_code.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/gen_code.c b/gen_code.c
index 686e61c..3f72446 100644
--- a/gen_code.c
+++ b/gen_code.c
@@ -191,18 +191,9 @@ ptree *t;
gen_arguments(t->l);
}
-
-/*Based on Dragon Book gen_code()*/
-void gen_expr(t)
+void gen_load(t)
ptree *t;
{
- if (!t) {
- fprintf(stderr, "GEN_EXPR: NOT T\n");
- return;
- }
-
-
- if (t->label == 0){
switch (t->type) {
case ID:
fprintf(stdout, "movq\t%d(%%rbp), %s\n",
@@ -227,6 +218,10 @@ ptree *t;
- t->l->attr.nval->offset * OFFSET_SIZE,
*reg_ptr);
break;
+ case SUB:
+ gen_load(t->l);
+ fprintf(stdout, "negq\t%s\n", *reg_ptr);
+ break;
default:
fprintf(stdout, "movq OTHER");
}