Mercurial > hg-old > index.cgi
comparison lwasm/pass1.c @ 342:7b4123dce741
Added basic symbol registration
author | lost@starbug |
---|---|
date | Wed, 24 Mar 2010 21:30:31 -0600 |
parents | 1a6fc6ebb31c |
children | 0215a0fbf61b |
comparison
equal
deleted
inserted
replaced
341:4e1cff60c293 | 342:7b4123dce741 |
---|---|
22 #include <config.h> | 22 #include <config.h> |
23 | 23 |
24 #include <stdio.h> | 24 #include <stdio.h> |
25 | 25 |
26 #include <lw_alloc.h> | 26 #include <lw_alloc.h> |
27 #include <lw_string.h> | |
27 | 28 |
28 #include "lwasm.h" | 29 #include "lwasm.h" |
30 #include "instab.h" | |
29 #include "input.h" | 31 #include "input.h" |
30 | 32 |
31 /* | 33 /* |
32 pass 1: parse the lines | 34 pass 1: parse the lines |
33 | 35 |
45 void do_pass1(asmstate_t *as) | 47 void do_pass1(asmstate_t *as) |
46 { | 48 { |
47 char *line; | 49 char *line; |
48 line_t *cl; | 50 line_t *cl; |
49 char *p1; | 51 char *p1; |
50 int stpace; | 52 int stspace; |
51 char *tok, *sym; | 53 char *tok, *sym; |
52 int opnum; | 54 int opnum; |
53 | 55 |
54 for (;;) | 56 for (;;) |
55 { | 57 { |
118 stspace = 0; | 120 stspace = 0; |
119 | 121 |
120 if (*p1 == '*' || *p1 == ';' || *p1 == '#' || !*p1) | 122 if (*p1 == '*' || *p1 == ';' || *p1 == '#' || !*p1) |
121 goto nextline; | 123 goto nextline; |
122 | 124 |
123 | 125 // find the end of the first token |
124 for (tok = p1; *p1 && !isspace(*p1) && *p1 != ':'; p1++) | 126 for (tok = p1; *p1 && !isspace(*p1) && *p1 != ':'; p1++) |
125 /* do nothing */ ; | 127 /* do nothing */ ; |
126 | 128 |
127 if (*p1 == ':' || stspace == 0) | 129 if (*p1 == ':' || stspace == 0) |
128 { | 130 { |
177 } | 179 } |
178 } | 180 } |
179 | 181 |
180 if (cl -> sym && cl -> symset == 0) | 182 if (cl -> sym && cl -> symset == 0) |
181 { | 183 { |
184 printf("Register symbol %s:", sym); | |
185 lw_expr_print(cl -> addr); | |
186 printf("\n"); | |
187 | |
182 // register symbol at line address | 188 // register symbol at line address |
189 if (!register_symbol(as, cl -> sym, cl -> addr, symbol_flag_none)) | |
190 { | |
191 // symbol error | |
192 } | |
183 } | 193 } |
184 | 194 |
185 lw_expr_print(cl -> addr); | 195 lw_expr_print(cl -> addr); |
186 printf("\n"); | 196 printf("\n"); |
187 // now parse the line | 197 // now parse the line |