Mercurial > hg-old > index.cgi
comparison lwasm/lwasm.h @ 346:a82c55070624
Added expression parsing infrastructure and misc fixes
author | lost@starbug |
---|---|
date | Sat, 27 Mar 2010 19:04:03 -0600 |
parents | 7416c3f9c321 |
children | 1649bc7bda5a |
comparison
equal
deleted
inserted
replaced
345:7416c3f9c321 | 346:a82c55070624 |
---|---|
24 | 24 |
25 #include <lw_expr.h> | 25 #include <lw_expr.h> |
26 #include <lw_stringlist.h> | 26 #include <lw_stringlist.h> |
27 #include <lw_stack.h> | 27 #include <lw_stack.h> |
28 | 28 |
29 | |
30 // these are allowed chars BELOW 0x80 for symbols | |
31 // first is symbol start chars, second is anywhere in symbol | |
32 #define SSYMCHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_@$" | |
33 #define SYMCHARS SSYMCHARS ".?0123456789" | |
34 | |
35 typedef struct asmstate_s asmstate_t; | |
36 | |
29 enum | 37 enum |
30 { | 38 { |
31 lwasm_expr_linelen = 1 | 39 lwasm_expr_linelen = 1, // length of ref'd line |
40 lwasm_expr_lineaddr = 2, // addr of ref'd line | |
41 lwasm_expr_nextbp = 3, // next branch point | |
42 lwasm_expr_prevbp = 4 // previous branch point | |
32 }; | 43 }; |
33 | 44 |
34 enum lwasm_output_e | 45 enum lwasm_output_e |
35 { | 46 { |
36 OUTPUT_DECB = 0, // DECB multirecord format | 47 OUTPUT_DECB = 0, // DECB multirecord format |
76 lw_expr_t addr; // assembly address of the line | 87 lw_expr_t addr; // assembly address of the line |
77 int len; // the "size" this line occupies (address space wise) (-1 if unknown) | 88 int len; // the "size" this line occupies (address space wise) (-1 if unknown) |
78 int insn; // number of insn in insn table | 89 int insn; // number of insn in insn table |
79 int symset; // set if the line symbol was consumed by the instruction | 90 int symset; // set if the line symbol was consumed by the instruction |
80 char *sym; // symbol, if any, on the line | 91 char *sym; // symbol, if any, on the line |
92 unsigned char *output; // output bytes | |
93 int outputl; // size of output | |
94 int outputbl; // size of output buffer | |
81 lwasm_error_t *err; // list of errors | 95 lwasm_error_t *err; // list of errors |
82 line_t *prev; // previous line | 96 line_t *prev; // previous line |
83 line_t *next; // next line | 97 line_t *next; // next line |
98 asmstate_t *as; // assembler state data ptr | |
84 }; | 99 }; |
85 | 100 |
86 enum | 101 enum |
87 { | 102 { |
88 symbol_flag_set = 1, // symbol was used with "set" | 103 symbol_flag_set = 1, // symbol was used with "set" |
111 char **lines; // macro lines | 126 char **lines; // macro lines |
112 int numlines; // number lines in macro | 127 int numlines; // number lines in macro |
113 macrotab_t *next; // next macro in list | 128 macrotab_t *next; // next macro in list |
114 }; | 129 }; |
115 | 130 |
116 typedef struct | 131 struct asmstate_s |
117 { | 132 { |
118 int output_format; // output format | 133 int output_format; // output format |
119 int target; // assembly target | 134 int target; // assembly target |
120 int debug_level; // level of debugging requested | 135 int debug_level; // level of debugging requested |
121 int flags; // assembly flags | 136 int flags; // assembly flags |
125 int skipcond; // skipping a condition? | 140 int skipcond; // skipping a condition? |
126 int skipmacro; // are we skipping in a macro? | 141 int skipmacro; // are we skipping in a macro? |
127 | 142 |
128 line_t *line_head; // start of lines list | 143 line_t *line_head; // start of lines list |
129 line_t *line_tail; // tail of lines list | 144 line_t *line_tail; // tail of lines list |
145 | |
146 line_t *cl; // current line pointer | |
130 | 147 |
131 int context; // the current "context" | 148 int context; // the current "context" |
132 int nextcontext; // the next available context | 149 int nextcontext; // the next available context |
133 | 150 |
134 symtab_t symtab; // meta data for the symbol table | 151 symtab_t symtab; // meta data for the symbol table |
138 char *output_file; // output file name | 155 char *output_file; // output file name |
139 lw_stringlist_t input_files; // files to assemble | 156 lw_stringlist_t input_files; // files to assemble |
140 void *input_data; // opaque data used by the input system | 157 void *input_data; // opaque data used by the input system |
141 lw_stringlist_t include_list; // include paths | 158 lw_stringlist_t include_list; // include paths |
142 lw_stack_t file_dir; // stack of the "current file" dir | 159 lw_stack_t file_dir; // stack of the "current file" dir |
143 } asmstate_t; | 160 }; |
144 | 161 |
145 #ifndef ___symbol_c_seen___ | 162 #ifndef ___symbol_c_seen___ |
146 | 163 |
147 extern struct symtabe *register_symbol(asmstate_t *as, line_t *cl, char *sym, lw_expr_t value, int flags); | 164 extern struct symtabe *register_symbol(asmstate_t *as, line_t *cl, char *sym, lw_expr_t value, int flags); |
148 extern struct symtabe *lookup_symbol(asmstate_t *as, line_t *cl, char *sym, int context, int version); | 165 extern struct symtabe *lookup_symbol(asmstate_t *as, line_t *cl, char *sym, int context, int version); |
151 | 168 |
152 #ifndef ___lwasm_c_seen___ | 169 #ifndef ___lwasm_c_seen___ |
153 | 170 |
154 extern void lwasm_register_error(asmstate_t *as, line_t *cl, const char *msg, ...); | 171 extern void lwasm_register_error(asmstate_t *as, line_t *cl, const char *msg, ...); |
155 extern int lwasm_next_context(asmstate_t *as); | 172 extern int lwasm_next_context(asmstate_t *as); |
173 extern void lwasm_emit(line_t *cl, int byte); | |
174 extern void lwasm_emitop(line_t *cl, int opc); | |
156 | 175 |
157 #endif | 176 #endif |
158 | 177 |
178 #define OPLEN(op) (((op)>0xFF)?2:1) | |
159 | 179 |
160 #endif /* ___lwasm_h_seen___ */ | 180 #endif /* ___lwasm_h_seen___ */ |