diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-09 01:00:40 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-09 01:00:40 -0400 |
commit | 64fbe9da1ab872b27b5f4dd3b46eb1a7b69d8245 (patch) | |
tree | 3d52fe019fc72ea0152e48792e77a5c45e825965 | |
parent | 4cdbd4062dfe9266a4d7facbad00ba691e194acd (diff) |
Add PCALL generation code
-rw-r--r-- | gen_code.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -177,14 +177,24 @@ ptree *t; if (!strcmp(t->l->attr.nval->name, "write")) { GEN_EXPR(t->r); - fprintf(stdout, "mov %s, %%rsi\n", *reg_ptr); - fprintf(stdout, "leaq int_print(%%rip), %%rdi\n"); - fprintf(stdout, "mov $0, %%rax\n"); + fprintf(stdout, "movq %s, %%rsi\n", *reg_ptr); + fprintf(stdout, "leaq int_print(%%rip)," + "%%rdi\n"); + fprintf(stdout, "movq $0, %%rax\n"); fprintf(stdout, "call printf\n"); + break; } else if (!strcmp(t->l->attr.nval->name, "read")) { fprintf(stderr,"Read\n"); + break; } - fprintf(stderr, "PCALL\n"); + + fprintf(stdout, "subq $%d, %%rsp\n", + t->l->attr.nval->func_info->argc * OFFSET_SIZE); + gen_arguments(t->r); + + fprintf(stdout, "call\t%s\n", t->l->attr.nval->name); + + break; case FCALL: if (t->l->ret_type == INT) { |