fixed bug in prepareStackForAbsOpt (rtemgr.c).
[bugg-scheme-compiler.git] / src / c / arch.c~
blobf51fae644825f94cfa0b15ef349868817a1d4431
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];