comparison lwasm/pass1.c @ 344:0215a0fbf61b

Added assembly error system and additional checks for symbol syntax
author lost@starbug
date Thu, 25 Mar 2010 22:06:50 -0600
parents 7b4123dce741
children 7416c3f9c321
comparison
equal deleted inserted replaced
343:b4157778d354 344:0215a0fbf61b
64 cl = lw_alloc(sizeof(line_t)); 64 cl = lw_alloc(sizeof(line_t));
65 cl -> next = NULL; 65 cl -> next = NULL;
66 cl -> prev = as -> line_tail; 66 cl -> prev = as -> line_tail;
67 cl -> len = -1; 67 cl -> len = -1;
68 cl -> insn = -1; 68 cl -> insn = -1;
69 cl -> err = NULL;
69 if (!as -> line_tail) 70 if (!as -> line_tail)
70 { 71 {
71 as -> line_head = cl; 72 as -> line_head = cl;
72 cl -> addr = lw_expr_build(lw_expr_type_int, 0); 73 cl -> addr = lw_expr_build(lw_expr_type_int, 0);
73 } 74 }
163 { 164 {
164 cl -> insn = -1; 165 cl -> insn = -1;
165 if (*tok != ';' && *tok != '*') 166 if (*tok != ';' && *tok != '*')
166 { 167 {
167 // bad opcode; check for macro here 168 // bad opcode; check for macro here
169 lwasm_register_error(as, cl, "Bad opcode");
168 } 170 }
169 } 171 }
170 else 172 else
171 { 173 {
172 cl -> insn = opnum; 174 cl -> insn = opnum;
173 // call parse function 175 // call parse function
174 176
175 if (*p1 && !isspace(*p1)) 177 if (*p1 && !isspace(*p1))
176 { 178 {
177 // flag bad operand error 179 // flag bad operand error
180 lwasm_register_error(as, cl, "Bad operand (%s)", p1);
178 } 181 }
179 } 182 }
180 } 183 }
181 184
182 if (cl -> sym && cl -> symset == 0) 185 if (cl -> sym && cl -> symset == 0)
184 printf("Register symbol %s:", sym); 187 printf("Register symbol %s:", sym);
185 lw_expr_print(cl -> addr); 188 lw_expr_print(cl -> addr);
186 printf("\n"); 189 printf("\n");
187 190
188 // register symbol at line address 191 // register symbol at line address
189 if (!register_symbol(as, cl -> sym, cl -> addr, symbol_flag_none)) 192 if (!register_symbol(as, cl, cl -> sym, cl -> addr, symbol_flag_none))
190 { 193 {
191 // symbol error 194 // symbol error
195 lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym);
192 } 196 }
193 } 197 }
194 198
195 lw_expr_print(cl -> addr); 199 lw_expr_print(cl -> addr);
196 printf("\n"); 200 printf("\n");