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
10#define STACK_SIZE 64
11#define JMP_STACK_SIZE 32
12#define MEM_SIZE 1024
13#define VARS_SIZE 64
14
15typedef struct Cotton Cotton;
16
17typedef struct {
18 char *name;
19 void (*code)(Cotton *c);
20} Word;
21
22struct Cotton {
23 int stack[STACK_SIZE];
24 int stack_p;
25
26 int jmp_stack[JMP_STACK_SIZE];
27 int jmp_stack_p;
28
29 int mem[MEM_SIZE];
30 int instruct_p;
31 int mem_len;
32
33 int vars[VARS_SIZE];
34};
35
36void cotton_init
37(Cotton *c);
38
39void push
40(Cotton *c, int v);
41
42int pop
43(Cotton *c);
44
45#endif