diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-09 09:34:50 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-09 09:34:50 -0400 |
commit | 3004a96a9bba4bf645bc072ef564f4debb509057 (patch) | |
tree | 6478f95d66860bda00f78339d45c8e5e6dae2287 | |
parent | dd7ae3ded95d2a2d110507ad32c17c771422c360 (diff) |
Add SUB (NEG) to gen_load
-rw-r--r-- | gen_code.c | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -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"); } |