comparison lwasm/lwasm.c @ 366:433dbc18fb41

Make byte overflow detection for 8 bit immediate not fail with COM operator This is a horrible hack. Add a quick and dirty context to expression parsing so that it knows whether an 8 bit or 16 bit complement is required. The 8 bit complement will just discard anything above bit 7. When returning an operator back with lwasm_whichop(), the result will still be "COM" which should allow other things to keep working as they already do. This does prevent byte overflows when the complement operator is used, however, and since those were introduced, there were problems building Nitros9 among other things. This fix allows Nitros9 to build again.
author William Astle <lost@l-w.ca>
date Tue, 02 Jun 2015 20:58:14 -0600
parents 433851a26794
children 8764142b3192
comparison
equal deleted inserted replaced
365:3f8abaac214c 366:433dbc18fb41
730 } 730 }
731 731
732 lw_expr_t lwasm_parse_expr(asmstate_t *as, char **p) 732 lw_expr_t lwasm_parse_expr(asmstate_t *as, char **p)
733 { 733 {
734 lw_expr_t e; 734 lw_expr_t e;
735 735
736 e = lw_expr_parse(p, as); 736 if (as->exprwidth != 16)
737 737 {
738 lw_expr_setwidth(as->exprwidth);
739 e = lw_expr_parse(p, as);
740 lw_expr_setwidth(0);
741 }
742 else
743 {
744 e = lw_expr_parse(p, as);
745 }
738 return e; 746 return e;
739 } 747 }
740 748
741 int lwasm_reduce_expr(asmstate_t *as, lw_expr_t expr) 749 int lwasm_reduce_expr(asmstate_t *as, lw_expr_t expr)
742 { 750 {