Added runtime symbol table
[bugg-scheme-compiler.git] / src / c / arch.c
blob2e062938b7bfa42640c37e11b4d5b7d4ce4e048c
1 /* support for the simulated micro-architecture */
3 #include "arch.h"
4 #include "assertions.h"
5 #include <stdlib.h>
7 int MAX_STACK_SIZE;
9 void initArchitecture(int stackSize, int regsCount)
11 MAX_STACK_SIZE = stackSize;
12 stack = (int*)malloc( stackSize * sizeof(int) );
13 sp = 0;
14 fp = 0;
16 r = (int*)malloc( regsCount * sizeof(int) );
19 void push(int x)
21 ASSERT_ALWAYS(sp < MAX_STACK_SIZE,"");
23 stack[sp++] = x;
26 int pop()
28 ASSERT_ALWAYS(sp > 0,"");
30 return stack[--sp];