diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-08 22:23:44 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-08 22:34:00 -0400 |
commit | 57bc5ca2c7044658f446036cc5b75bf50de5bd24 (patch) | |
tree | e3d1ac4e0fbcc181676b899244b0ef4dc8bfa1fd | |
parent | e11eda53660f19bcbcede3bb25b09a71363cef21 (diff) |
Fix enter/leave function setup (stack frames)
-rw-r--r-- | gen_code.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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"); + } |