3b11d85445f54f460dad101a774094dd097139b4
[dcpu16] / as-dcpu16.h
1 #ifndef AS_DCPU16_H_PTFNJB09
2 #define AS_DCPU16_H_PTFNJB09
3
4 #include "dcpu16.h"
5
6 struct instruction_ {
7 char *label; /* set if a label points here */
8 char *opcode; /* tokenized instruction text */
9 struct operand_ *operands; /* list of operands */
10 unsigned int ready : 1; /* bytecode computed? */
11 unsigned int length; /* number of words of bytecode */
12 DCPU16_WORD instr_words[];
13 };
14
15
16 struct operand_ {
17 struct operand_ *next;
18 char *operand; /* tokenized operand text */
19 };
20
21
22 #define IL_SIZE(entries) (((entries) * sizeof(struct instruction_ *)) + sizeof(struct instruction_list_))
23
24 struct instruction_list_ {
25 size_t allocated;
26 size_t entries;
27 struct instruction_ *instr[];
28 };
29
30
31 /* note label table holds its own structs, not pointers like instruction list */
32 struct label_ {
33 char *label; /* name of label */
34 struct instruction_ **instr; /* pointer into instruction list table */
35 unsigned int ready : 1; /* do we know where this label is yet? */
36 DCPU16_WORD addr;
37 };
38
39 #define LL_SIZE(entries) (((entries) * sizeof(struct label_ *)) + sizeof(struct label_list_))
40
41 struct label_list_ {
42 size_t allocated;
43 size_t entries;
44 struct label_ label[];
45 };
46
47 #endif /* AS_DCPU16_H_PTFNJB09 */