1 /*
2   Stack
3   Fully hide the stack behind access procedures
4   JBS 15 June 1994
5 */
6 
7 #ifndef _STACK_
8 
9 #define _STACK_
10 
11 #include "types.h"
12 
13 #define STACK_SIZE 1024
14 
15 extern word stack_space[STACK_SIZE];
16 extern word *stack_ptr;
17 extern word *var_ptr;
18 
19 #define stack_base (&stack_space[STACK_SIZE])
20 
21 void stk_link(void);
22 void stk_throw(word);
23 void stk_unlink(void);
24 void stk_init(void);
25 
26 word stk_encode_stk(void);
27 word stk_encode_var(void);
28 void stk_decode_stk(word);
29 void stk_decode_var(word);
30 
31 
32 #define stk_push(v)             *--stack_ptr = (v)
33 #define stk_pop()               *stack_ptr++
34 
35 #define stk_get_var(i)          var_ptr[-i]
36 #define stk_set_var(i,v)        var_ptr[-i] = (v)
37 
38 #define stk_get_top()           *stack_ptr
39 #define stk_set_top(v)          *stack_ptr = (v)
40 
41 #define stk_get_abs(i)          stack_space[i]
42 #define stk_set_abs(i,v)        stack_space[i] = (v)
43 
44 #endif
45