comparison lwasm/lwasm.c @ 382:eacdae8a1575

Various bugfixes
author lost@starbug
date Sat, 15 May 2010 13:39:21 -0600
parents 1624a36f12a3
children cf8c92d70eb1
comparison
equal deleted inserted replaced
381:1624a36f12a3 382:eacdae8a1575
346 if (**p == '$') 346 if (**p == '$')
347 { 347 {
348 // hexadecimal constant 348 // hexadecimal constant
349 int v = 0, v2; 349 int v = 0, v2;
350 (*p)++; 350 (*p)++;
351
352 if (!strchr("0123456789abcdefABCDEF", **p)) 351 if (!strchr("0123456789abcdefABCDEF", **p))
353 return NULL; 352 return NULL;
354 353
355 while (**p && strchr("0123456789abcdefABCDEF", **p)) 354 while (**p && strchr("0123456789abcdefABCDEF", **p))
356 { 355 {
357 v2 = toupper(**p) - '0'; 356 v2 = toupper(**p) - '0';
358 if (v2 > 9) 357 if (v2 > 9)
359 v2 -= 7; 358 v2 -= 7;
360 val = val * 16 + v2; 359 v = v * 16 + v2;
361 (*p)++; 360 (*p)++;
362 } 361 }
363 return lw_expr_build(lw_expr_type_int, v); 362 return lw_expr_build(lw_expr_type_int, v);
364 } 363 }
365 364
375 while (**p && strchr("0123456789abcdefABCDEF", **p)) 374 while (**p && strchr("0123456789abcdefABCDEF", **p))
376 { 375 {
377 v2 = toupper(**p) - '0'; 376 v2 = toupper(**p) - '0';
378 if (v2 > 9) 377 if (v2 > 9)
379 v2 -= 7; 378 v2 -= 7;
380 val = val * 16 + v2; 379 v = v * 16 + v2;
381 (*p)++; 380 (*p)++;
382 } 381 }
383 return lw_expr_build(lw_expr_type_int, v); 382 return lw_expr_build(lw_expr_type_int, v);
384 } 383 }
385 384
392 if (!strchr("01234567", **p)) 391 if (!strchr("01234567", **p))
393 return NULL; 392 return NULL;
394 393
395 while (**p && strchr("01234567", **p)) 394 while (**p && strchr("01234567", **p))
396 { 395 {
397 val = val * 8 + (**p - '0'); 396 v = v * 8 + (**p - '0');
398 (*p)++; 397 (*p)++;
399 } 398 }
400 return lw_expr_build(lw_expr_type_int, v); 399 return lw_expr_build(lw_expr_type_int, v);
401 } 400 }
402 401
760 return rval; 759 return rval;
761 } 760 }
762 761
763 void lwasm_show_errors(asmstate_t *as) 762 void lwasm_show_errors(asmstate_t *as)
764 { 763 {
765 fprintf(stderr, "Errors encountered. FIXME - print out errors.\n"); 764 line_t *cl;
766 } 765 lwasm_error_t *e;
766
767 for (cl = as -> line_head; cl; cl = cl -> next)
768 {
769 if (!(cl -> err) && !(cl -> warn))
770 continue;
771 for (e = cl -> err; e; e = e -> next)
772 {
773 fprintf(stderr, "ERROR: %s\n", e -> mess);
774 }
775 for (e = cl -> warn; e; e = e -> next)
776 {
777 fprintf(stderr, "WARNING: %s\n", e -> mess);
778 }
779
780 fprintf(stderr, " LINE: %s\n", cl -> ltext);
781 }
782 }