diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-09 09:53:21 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-10-09 09:53:21 -0400 |
commit | e96b0e885aecc66377fc020a74169ceaea450a38 (patch) | |
tree | 5783660741ebbabcf8042db1675aa111aba1356c | |
parent | 13fbc5bf019d635926f1a49ff70843897375eee1 (diff) |
Fix save stack now resets reginster stack
-rw-r--r-- | gen_code.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -6,6 +6,9 @@ #include "pc.h" #include "scope.h" +char **stack_reg[1024]; +char ***reg_stack_save; + #define FLOAT_ERROR "Cannot produce code with reals\n" scope *cur_scope; @@ -40,6 +43,8 @@ int reg_cnt; "pushq\t%%r14\n"\ "pushq\t%%r15\n"\ );\ + *reg_stack_save = reg_ptr;\ + reg_stack_save++;\ } #define STACK_LOAD {\ @@ -58,6 +63,8 @@ int reg_cnt; "popq\t%%rcx\n"\ "popq\t%%rax\n"\ );\ + reg_stack_save--;\ + reg_ptr = *reg_stack_save;\ } int gen_label(t) @@ -404,6 +411,10 @@ char *name; reg_ptr = reg_stack; reg_cnt = 13; + reg_stack_save = stack_reg; + fprintf(stderr, "%p\n", reg_stack_save); + + fprintf(stdout, "\n.globl %s\n", name); fprintf(stdout, ".type %s, @function\n%s:\n", name, name); |