fixed bug in prepareStackForAbsOpt (rtemgr.c).
[bugg-scheme-compiler.git] / src / c / arch.h
blobd254795dd03658415117c1473a6783166e64b455
1 /* Architecture */
3 #ifndef __ARCH_H
4 #define __ARCH_H
6 void initArchitecture(int stackSize, int regsCount);
8 /* Stack */
9 extern int* stack;
10 extern int sp;
11 extern int fp;
13 void push(int x);
14 int pop();
16 /* The stack **WHILE IN A USER PROCEDURE**:
17 fp -> | |
18 | fp | - the old fp (before this application)
19 | ret | - return address
20 | env | - points to the enviroment vector
21 | n | - number of arguments
22 | A0 | - argument 0
23 | A1 | - argument 1
24 | ... | - ...
25 ST_FRMEND -> | An-1 | - argument n-1
27 Note: ST_FRMEND points to the end of the current actvation frame (in fact,
28 to the last element: An-1). Note that ST_FRMEND does not have to be
29 equal to [the old fp + 1] (in case we are in the middle of an
30 application and already pushed some arguments onto the stack).
32 Note: sp does NOT have to be equal to fp - for example if we are in the
33 middle of applying a procedure and already pushed some arguments
34 on to the stack (then sp has changed, but fp has not).
36 Macros for user procedures:
38 #define ST_ARG(n) (stack[fp-5-(n)])
39 #define ST_ARG_COUNT() (stack[fp-4])
40 #define ST_OLDFP() (stack[fp-1])
41 #define ST_RET() (stack[fp-2])
42 #define ST_ENV() (stack[fp-3])
43 #define ST_FRMEND() (fp-4-stack[fp-4])
44 #define RETURN() goto *pop()
46 /* General Purpose Registers */
47 extern int* r;
48 extern int r_res;
50 #endif