aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-10-08 22:23:44 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-10-08 22:34:00 -0400
commit57bc5ca2c7044658f446036cc5b75bf50de5bd24 (patch)
treee3d1ac4e0fbcc181676b899244b0ef4dc8bfa1fd
parente11eda53660f19bcbcede3bb25b09a71363cef21 (diff)
Fix enter/leave function setup (stack frames)
-rw-r--r--gen_code.c5
1 files changed, 5 insertions, 0 deletions
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");
+
}