main soggy/cotton / src / cotton.h
 1#ifndef COTTON_H
 2#define COTTON_H
 3
 4#define OP_PUSH        0
 5#define OP_CALL        1
 6#define OP_KILL        2
 7#define OP_JMP         3
 8#define OP_FJMP        4
 9#define OP_PUSH_STR	   5
10
11#define STACK_SIZE     256
12#define JMP_STACK_SIZE 64
13#define MEM_SIZE       4096
14#define VARS_SIZE      256
15
16typedef struct Cotton Cotton;
17
18typedef struct {
19    
20    char *name;
21    void (*code)(Cotton *c);
22
23} Cog;
24
25struct Cotton {
26
27	int stack[STACK_SIZE];
28    int stack_p;
29
30    int jmp_stack[JMP_STACK_SIZE];
31    int jmp_stack_p; 
32
33    int mem[MEM_SIZE];
34    int instruct_p;
35    int mem_len;
36
37    int vars[VARS_SIZE];
38
39};
40
41void cotton_init
42(Cotton *c);
43
44void push
45(Cotton *c, int v);
46
47int pop
48(Cotton *c);
49
50#endif