From 57bc5ca2c7044658f446036cc5b75bf50de5bd24 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Tue, 8 Oct 2019 22:23:44 -0400 Subject: Fix enter/leave function setup (stack frames) --- gen_code.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gen_code.c b/gen_code.c index be56e83..52aac28 100644 --- a/gen_code.c +++ b/gen_code.c @@ -210,5 +210,10 @@ char *name; fprintf(stdout, "\n.globl %s\n", name); fprintf(stdout, ".type %s, @function\n%s:\n", name, name); + fprintf(stdout, "pushq\t%%rbp\nmovq\t%%rsp, %%rbp\n"); + fprintf(stdout, "subq\t $%d, %%rsp\n", cur_scope->offset * OFFSET_SIZE); gen_statement_order(t); + + fprintf(stdout, "movq\t%%rbp, %%rsp\npop\t%%rbp\nret\n\n"); + } -- cgit v1.1