aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gen_code.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gen_code.c b/gen_code.c
index e4f7936..45dbf6c 100644
--- a/gen_code.c
+++ b/gen_code.c
@@ -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);