comparison lwasm/lwasm.h @ 363:d96c30e60ddf

Added pass2 and various supporting logic including symbol lookups
author lost@starbug
date Tue, 06 Apr 2010 21:03:19 -0600
parents 105393e31f20
children 34dfc9747f23
comparison
equal deleted inserted replaced
362:4867f18c872f 363:d96c30e60ddf
37 enum 37 enum
38 { 38 {
39 lwasm_expr_linelen = 1, // length of ref'd line 39 lwasm_expr_linelen = 1, // length of ref'd line
40 lwasm_expr_lineaddr = 2, // addr of ref'd line 40 lwasm_expr_lineaddr = 2, // addr of ref'd line
41 lwasm_expr_nextbp = 3, // next branch point 41 lwasm_expr_nextbp = 3, // next branch point
42 lwasm_expr_prevbp = 4 // previous branch point 42 lwasm_expr_prevbp = 4, // previous branch point
43 lwasm_expr_syment = 5, // symbol table entry
44 lwasm_expr_import = 6 // symbol import entry
43 }; 45 };
44 46
45 enum lwasm_output_e 47 enum lwasm_output_e
46 { 48 {
47 OUTPUT_DECB = 0, // DECB multirecord format 49 OUTPUT_DECB = 0, // DECB multirecord format
102 lw_expr_t expr; 104 lw_expr_t expr;
103 int id; 105 int id;
104 struct line_expr_s *next; 106 struct line_expr_s *next;
105 }; 107 };
106 108
109 typedef struct line_s line_t;
110
107 typedef struct exportlist_s exportlist_t; 111 typedef struct exportlist_s exportlist_t;
108 struct exportlist_s 112 struct exportlist_s
109 { 113 {
110 char *symbol; // symbol to export 114 char *symbol; // symbol to export
115 line_t *line; // line the export is on
111 exportlist_t *next; // next in the export list 116 exportlist_t *next; // next in the export list
112 }; 117 };
113 118
114 typedef struct importlist_s importlist_t; 119 typedef struct importlist_s importlist_t;
115 struct importlist_s 120 struct importlist_s
116 { 121 {
117 char *symbol; // symbol to import 122 char *symbol; // symbol to import
118 importlist_t *next; // next in the import list 123 importlist_t *next; // next in the import list
119 }; 124 };
120 125
121 typedef struct line_s line_t;
122 struct line_s 126 struct line_s
123 { 127 {
124 lw_expr_t addr; // assembly address of the line 128 lw_expr_t addr; // assembly address of the line
125 int len; // the "size" this line occupies (address space wise) (-1 if unknown) 129 int len; // the "size" this line occupies (address space wise) (-1 if unknown)
126 int insn; // number of insn in insn table 130 int insn; // number of insn in insn table
141 int pb; // pass forward post byte 145 int pb; // pass forward post byte
142 int lint; // pass forward integer 146 int lint; // pass forward integer
143 int lint2; // another pass forward integer 147 int lint2; // another pass forward integer
144 asmstate_t *as; // assembler state data ptr 148 asmstate_t *as; // assembler state data ptr
145 int pragmas; // pragmas in effect for the line 149 int pragmas; // pragmas in effect for the line
150 int context; // the symbol context number
146 }; 151 };
147 152
148 enum 153 enum
149 { 154 {
150 symbol_flag_set = 1, // symbol was used with "set" 155 symbol_flag_set = 1, // symbol was used with "set"
188 int skipmacro; // are we skipping in a macro? 193 int skipmacro; // are we skipping in a macro?
189 int endseen; // have we seen an "end" pseudo? 194 int endseen; // have we seen an "end" pseudo?
190 int execaddr; // address from "end" 195 int execaddr; // address from "end"
191 int inmod; // inside an os9 module? 196 int inmod; // inside an os9 module?
192 unsigned char crc[3]; // crc accumulator 197 unsigned char crc[3]; // crc accumulator
198 int badsymerr; // throw error on undef sym if set
193 199
194 line_t *line_head; // start of lines list 200 line_t *line_head; // start of lines list
195 line_t *line_tail; // tail of lines list 201 line_t *line_tail; // tail of lines list
196 202
197 line_t *cl; // current line pointer 203 line_t *cl; // current line pointer
215 }; 221 };
216 222
217 #ifndef ___symbol_c_seen___ 223 #ifndef ___symbol_c_seen___
218 224
219 extern struct symtabe *register_symbol(asmstate_t *as, line_t *cl, char *sym, lw_expr_t value, int flags); 225 extern struct symtabe *register_symbol(asmstate_t *as, line_t *cl, char *sym, lw_expr_t value, int flags);
220 extern struct symtabe *lookup_symbol(asmstate_t *as, line_t *cl, char *sym, int context, int version); 226 extern struct symtabe *lookup_symbol(asmstate_t *as, line_t *cl, char *sym);
221 227
222 #endif 228 #endif
223 229
224 #ifndef ___lwasm_c_seen___ 230 #ifndef ___lwasm_c_seen___
225 231
237 extern void skip_operand(char **p); 243 extern void skip_operand(char **p);
238 244
239 extern int lwasm_lookupreg2(const char *rlist, char **p); 245 extern int lwasm_lookupreg2(const char *rlist, char **p);
240 extern int lwasm_lookupreg3(const char *rlist, char **p); 246 extern int lwasm_lookupreg3(const char *rlist, char **p);
241 247
248 extern void lwasm_show_errors(asmstate_t *as);
249
250 extern int lwasm_reduce_expr(asmstate_t *as, lw_expr_t expr);
251
242 #endif 252 #endif
243 253
244 #define OPLEN(op) (((op)>0xFF)?2:1) 254 #define OPLEN(op) (((op)>0xFF)?2:1)
245 #define CURPRAGMA(l,p) (((l)->pragmas & (p)) ? 1 : 0) 255 #define CURPRAGMA(l,p) (((l)->pragmas & (p)) ? 1 : 0)
246 256