From 64fbe9da1ab872b27b5f4dd3b46eb1a7b69d8245 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 9 Oct 2019 01:00:40 -0400 Subject: Add PCALL generation code --- gen_code.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/gen_code.c b/gen_code.c index c244dcb..2e21244 100644 --- a/gen_code.c +++ b/gen_code.c @@ -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) { -- cgit v1.1