Mercurial > hg-old > index.cgi
annotate lwasm/pass1.c @ 411:cac204676434
Allow symbols to start with digits if they contain $, ?, or @; numbered locals
author | lost@l-w.ca |
---|---|
date | Mon, 09 Aug 2010 00:10:24 -0600 |
parents | acaafc70044b |
children | 4b137a8cf32a |
rev | line source |
---|---|
332 | 1 /* |
2 pass1.c | |
3 | |
4 Copyright © 2010 William Astle | |
5 | |
6 This file is part of LWTOOLS. | |
7 | |
8 LWTOOLS is free software: you can redistribute it and/or modify it under the | |
9 terms of the GNU General Public License as published by the Free Software | |
10 Foundation, either version 3 of the License, or (at your option) any later | |
11 version. | |
12 | |
13 This program is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
16 more details. | |
17 | |
18 You should have received a copy of the GNU General Public License along with | |
19 this program. If not, see <http://www.gnu.org/licenses/>. | |
20 */ | |
21 | |
22 #include <config.h> | |
23 | |
24 #include <stdio.h> | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
25 #include <string.h> |
332 | 26 |
27 #include <lw_alloc.h> | |
342 | 28 #include <lw_string.h> |
332 | 29 |
30 #include "lwasm.h" | |
342 | 31 #include "instab.h" |
332 | 32 #include "input.h" |
33 | |
389
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
34 extern int expand_macro(asmstate_t *as, line_t *l, char **p, char *opc); |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
35 extern int expand_struct(asmstate_t *as, line_t *l, char **p, char *opc); |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
36 |
337 | 37 /* |
38 pass 1: parse the lines | |
340 | 39 |
40 line format: | |
41 | |
42 [<symbol>] <opcode> <operand>[ <comment>] | |
43 | |
44 If <symbol> is followed by a :, whitespace may precede the symbol | |
45 | |
46 A line may optionally start with a number which must not be preceded by | |
47 white space and must be followed by a single whitespace character. After | |
48 that whitespace character, the line is parsed as if it had no line number. | |
49 | |
337 | 50 */ |
332 | 51 void do_pass1(asmstate_t *as) |
52 { | |
53 char *line; | |
337 | 54 line_t *cl; |
340 | 55 char *p1; |
342 | 56 int stspace; |
340 | 57 char *tok, *sym; |
58 int opnum; | |
383
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
59 int lc = 1; |
332 | 60 for (;;) |
61 { | |
340 | 62 sym = NULL; |
332 | 63 line = input_readline(as); |
64 if (!line) | |
65 break; | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
66 if (line[0] == 1 && line[1] == 1) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
67 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
68 // special internal directive |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
69 // these DO NOT appear in the output anywhere |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
70 // they are generated by the parser to pass information |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
71 // forward |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
72 for (p1 = line + 2; *p1 && !isspace(*p1); p1++) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
73 /* do nothing */ ; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
74 *p1++ = '\0'; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
75 if (!strcmp(line + 2, "SETCONTEXT")) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
76 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
77 as -> context = strtol(p1, NULL, 10); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
78 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
79 lw_free(line); |
383
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
80 lc = 1; |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
81 continue; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
82 } |
372
90de73ba0cac
Created a useful debug framework and adjusted lw_expr_print() to return a "static" dynamic string
lost@starbug
parents:
370
diff
changeset
|
83 debug_message(as, 75, "Read line: %s", line); |
337 | 84 |
85 cl = lw_alloc(sizeof(line_t)); | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
86 memset(cl, 0, sizeof(line_t)); |
374 | 87 cl -> outputl = -1; |
383
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
88 cl -> linespec = lw_strdup(input_curspec(as)); |
337 | 89 cl -> prev = as -> line_tail; |
90 cl -> insn = -1; | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
345
diff
changeset
|
91 cl -> as = as; |
354 | 92 cl -> inmod = as -> inmod; |
93 cl -> csect = as -> csect; | |
360
7d91ab7ac7d6
Indexed stage 2; set line structure to track pragmas in effect for that line
lost@starbug
parents:
354
diff
changeset
|
94 cl -> pragmas = as -> pragmas; |
363
d96c30e60ddf
Added pass2 and various supporting logic including symbol lookups
lost@starbug
parents:
360
diff
changeset
|
95 cl -> context = as -> context; |
382 | 96 cl -> ltext = lw_strdup(line); |
389
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
97 cl -> soff = -1; |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
98 cl -> dshow = -1; |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
99 cl -> dsize = 0; |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
100 cl -> dptr = NULL; |
385 | 101 as -> cl = cl; |
337 | 102 if (!as -> line_tail) |
103 { | |
104 as -> line_head = cl; | |
105 cl -> addr = lw_expr_build(lw_expr_type_int, 0); | |
106 } | |
107 else | |
108 { | |
109 lw_expr_t te; | |
351 | 110 |
383
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
111 cl -> lineno = as -> line_tail -> lineno + 1; |
337 | 112 as -> line_tail -> next = cl; |
351 | 113 |
114 // set the line address | |
337 | 115 te = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, cl -> prev); |
116 cl -> addr = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, cl -> prev -> addr, te); | |
117 lw_expr_destroy(te); | |
385 | 118 lwasm_reduce_expr(as, cl -> addr); |
119 // lw_expr_simplify(cl -> addr, as); | |
351 | 120 |
121 // carry DP value forward | |
122 cl -> dpval = cl -> prev -> dpval; | |
383
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
123 |
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
124 } |
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
125 if (!lc && strcmp(cl -> linespec, cl -> prev -> linespec)) |
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
126 lc = 1; |
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
127 if (lc) |
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
128 { |
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
129 cl -> lineno = 1; |
848d3cca8078
Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents:
382
diff
changeset
|
130 lc = 0; |
337 | 131 } |
132 as -> line_tail = cl; | |
340 | 133 // blank lines don't count for anything |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
134 // except a local symbol context break |
340 | 135 if (!*line) |
136 { | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
137 as -> context = lwasm_next_context(as); |
340 | 138 goto nextline; |
139 } | |
140 | |
141 // skip comments | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
142 // commends do not create a context break |
340 | 143 if (*line == '*' || *line == ';' || *line == '#') |
144 goto nextline; | |
145 | |
146 p1 = line; | |
147 if (isdigit(*p1)) | |
148 { | |
149 // skip line number | |
150 while (*p1 && isdigit(*p1)) | |
151 p1++; | |
152 if (!*p1 && !isspace(*p1)) | |
153 p1 = line; | |
411
cac204676434
Allow symbols to start with digits if they contain $, ?, or @; numbered locals
lost@l-w.ca
parents:
410
diff
changeset
|
154 else if (*p1 && !isspace(*p1)) |
cac204676434
Allow symbols to start with digits if they contain $, ?, or @; numbered locals
lost@l-w.ca
parents:
410
diff
changeset
|
155 p1 = line; |
340 | 156 else if (*p1 && isspace(*p1)) |
157 p1++; | |
158 } | |
159 | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
160 // blank line - context break |
340 | 161 if (!*p1) |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
162 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
163 as -> context = lwasm_next_context(as); |
340 | 164 goto nextline; |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
165 } |
340 | 166 |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
167 // comment - no context break |
340 | 168 if (*p1 == '*' || *p1 == ';' || *p1 == '#') |
169 goto nextline; | |
170 | |
171 if (isspace(*p1)) | |
172 { | |
173 for (; *p1 && isspace(*p1); p1++) | |
174 /* do nothing */ ; | |
175 stspace = 1; | |
176 } | |
177 else | |
178 stspace = 0; | |
179 | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
180 if (*p1 == '*' || *p1 == ';' || *p1 == '#') |
340 | 181 goto nextline; |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
182 if (!*p1) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
183 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
184 // nothing but whitespace - context break |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
185 as -> context = lwasm_next_context(as); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
186 goto nextline; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
187 } |
340 | 188 |
342 | 189 // find the end of the first token |
410 | 190 for (tok = p1; *p1 && !isspace(*p1) && *p1 != ':' && *p1 != '='; p1++) |
340 | 191 /* do nothing */ ; |
192 | |
410 | 193 if (*p1 == ':' || *p1 == '=' || stspace == 0) |
340 | 194 { |
195 // have a symbol here | |
196 sym = lw_strndup(tok, p1 - tok); | |
197 if (*p1 == ':') | |
198 p1++; | |
199 for (; *p1 && isspace(*p1); p1++) | |
200 /* do nothing */ ; | |
201 | |
410 | 202 if (*p1 == '=') |
203 { | |
204 tok = p1++; | |
205 } | |
206 else | |
207 { | |
208 for (tok = p1; *p1 && !isspace(*p1); p1++) | |
209 /* do nothing */ ; | |
210 } | |
340 | 211 } |
370 | 212 if (sym) |
213 cl -> sym = lw_strdup(sym); | |
340 | 214 cl -> symset = 0; |
215 | |
216 // tok points to the opcode for the line or NUL if none | |
217 if (*tok) | |
218 { | |
219 // look up operation code | |
220 sym = lw_strndup(tok, p1 - tok); | |
370 | 221 for (; *p1 && isspace(*p1); p1++) |
340 | 222 /* do nothing */ ; |
223 | |
224 for (opnum = 0; instab[opnum].opcode; opnum++) | |
225 { | |
226 if (!strcasecmp(instab[opnum].opcode, sym)) | |
227 break; | |
228 } | |
229 | |
230 // p1 points to the start of the operand | |
231 | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
232 // if we're inside a macro definition and not at ENDM, |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
233 // add the line to the macro definition and continue |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
234 if (as -> inmacro && !(instab[opnum].flags & lwasm_insn_endm)) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
235 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
236 add_macro_line(as, line); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
237 goto linedone; |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
238 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
239 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
240 // if skipping a condition and the operation code doesn't |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
241 // operate within a condition (not a conditional) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
242 // do nothing |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
243 if (as -> skipcond && !(instab[opnum].flags & lwasm_insn_cond)) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
244 goto linedone; |
389
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
245 |
340 | 246 if (instab[opnum].opcode == NULL) |
247 { | |
248 cl -> insn = -1; | |
249 if (*tok != ';' && *tok != '*') | |
250 { | |
251 // bad opcode; check for macro here | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
252 if (expand_macro(as, cl, &p1, sym) != 0) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
253 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
254 // macro expansion failed |
389
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
255 if (expand_struct(as, cl, &p1, sym) != 0) |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
256 { |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
257 // structure expansion failed |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
258 lwasm_register_error(as, cl, "Bad opcode"); |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
259 } |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
260 } |
340 | 261 } |
262 } | |
263 else | |
264 { | |
265 cl -> insn = opnum; | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
266 // no parse func means operand doesn't matter |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
267 if (instab[opnum].parse) |
340 | 268 { |
389
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
269 if (as -> instruct == 0 || instab[opnum].flags & lwasm_insn_struct) |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
270 { |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
271 cl -> len = -1; |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
272 // call parse function |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
273 (instab[opnum].parse)(as, cl, &p1); |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
274 |
389
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
275 if (*p1 && !isspace(*p1)) |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
276 { |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
277 // flag bad operand error |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
278 lwasm_register_error(as, cl, "Bad operand (%s)", p1); |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
279 } |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
280 } |
fbb7bfed8076
Added in structure support and fixed up some warts in the listing code (by adding more warts)
lost@l-w.ca
parents:
385
diff
changeset
|
281 else if (as -> instruct == 1) |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
282 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
283 lwasm_register_error(as, cl, "Bad operand (%s)", p1); |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
284 } |
340 | 285 } |
286 } | |
287 } | |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
288 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
289 linedone: |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
290 lw_free(sym); |
340 | 291 |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
292 if (!as -> skipcond && !as -> inmacro) |
340 | 293 { |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
294 if (cl -> sym && cl -> symset == 0) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
295 { |
372
90de73ba0cac
Created a useful debug framework and adjusted lw_expr_print() to return a "static" dynamic string
lost@starbug
parents:
370
diff
changeset
|
296 debug_message(as, 50, "Register symbol %s: %s", cl -> sym, lw_expr_print(cl -> addr)); |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
297 |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
298 // register symbol at line address |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
299 if (!register_symbol(as, cl, cl -> sym, cl -> addr, symbol_flag_none)) |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
300 { |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
301 // symbol error |
370 | 302 // lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym); |
345
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
303 } |
7416c3f9c321
Basic macro processor ported forward; added context break handling for local symbols
lost@starbug
parents:
344
diff
changeset
|
304 } |
372
90de73ba0cac
Created a useful debug framework and adjusted lw_expr_print() to return a "static" dynamic string
lost@starbug
parents:
370
diff
changeset
|
305 debug_message(as, 40, "Line address: %s", lw_expr_print(cl -> addr)); |
340 | 306 } |
307 | |
308 nextline: | |
332 | 309 lw_free(line); |
347 | 310 |
311 // if we've hit the "end" bit, finish out | |
312 if (as -> endseen) | |
313 return; | |
332 | 314 } |
315 } |