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