Mercurial > hg-old > index.cgi
comparison src/parse.c @ 68:cef25b0088e6
Fixed some problems detected by valgrind and testing
author | lost |
---|---|
date | Mon, 05 Jan 2009 06:14:41 +0000 |
parents | aa9d9fedfdf4 |
children | 90a5657d5408 |
comparison
equal
deleted
inserted
replaced
67:d5fe306f1ab1 | 68:cef25b0088e6 |
---|---|
113 | 113 |
114 // if we found no operation, check if we had a comment | 114 // if we found no operation, check if we had a comment |
115 // the reason this check is here is to allow for "private" | 115 // the reason this check is here is to allow for "private" |
116 // operation codes like "*pragma" which will be ignored by | 116 // operation codes like "*pragma" which will be ignored by |
117 // other assemblers | 117 // other assemblers |
118 // also skip empty ops | |
118 if (!(instab[opnum].opcode)) | 119 if (!(instab[opnum].opcode)) |
119 { | 120 { |
120 if (*opc == '*' || *opc == ';') | 121 if (*opc == '*' || *opc == ';' || !*opc) |
121 goto done_line; | 122 goto done_line; |
122 } | 123 } |
123 | 124 |
124 // now we have the opcode and the symbol, we can decide if we're | 125 // now we have the opcode and the symbol, we can decide if we're |
125 // actually going to do anything with this line | 126 // actually going to do anything with this line |
139 } | 140 } |
140 | 141 |
141 // second condition above | 142 // second condition above |
142 if (as -> skipcond && instab[opnum].iscond == 0) | 143 if (as -> skipcond && instab[opnum].iscond == 0) |
143 goto done_line; | 144 goto done_line; |
144 | |
145 // register symbol if the operation won't | |
146 if (sym && instab[opnum].setsym == 0) | |
147 { | |
148 if (as -> passnum == 1) | |
149 { | |
150 debug_message(1, "Registering symbol '%s' at %04X", sym, as -> addr); | |
151 if (lwasm_register_symbol(as, l, sym, as -> addr, SYMBOL_NORM) < 0) | |
152 l -> sym = NULL; | |
153 } | |
154 } | |
155 | 145 |
156 // we've registered the symbol as needed | 146 // we've registered the symbol as needed |
157 // now we need to check for a macro call IFF we don't collide with | 147 // now we need to check for a macro call IFF we don't collide with |
158 // an operation code; otherwise, call the operation function | 148 // an operation code; otherwise, call the operation function |
159 if (instab[opnum].opcode) | 149 if (instab[opnum].opcode) |
178 register_error(as, l, 1, "Uknown operation code: %s", opc); | 168 register_error(as, l, 1, "Uknown operation code: %s", opc); |
179 l -> badop = 1; | 169 l -> badop = 1; |
180 } | 170 } |
181 | 171 |
182 done_line: | 172 done_line: |
173 if (!(as -> skipcond || as -> inmacro)) | |
174 { | |
175 // register symbol if the operation didn't | |
176 if (sym && instab[opnum].setsym == 0) | |
177 { | |
178 if (as -> passnum == 1) | |
179 { | |
180 debug_message(1, "Registering symbol '%s' at %04X", sym, as -> addr); | |
181 if (lwasm_register_symbol(as, l, sym, as -> addr, SYMBOL_NORM) < 0) | |
182 l -> sym = NULL; | |
183 else | |
184 l -> addrset = 1; | |
185 } | |
186 } | |
187 } | |
188 | |
183 lwasm_free(opc); | 189 lwasm_free(opc); |
184 if (sym) | 190 if (sym) |
185 lwasm_free(sym); | 191 lwasm_free(sym); |
186 } | 192 } |