Mercurial > hg > index.cgi
comparison lwasm/insn_gen.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 | 3afb809c7add |
children | 8764142b3192 |
comparison
equal
deleted
inserted
replaced
365:3f8abaac214c | 366:433dbc18fb41 |
---|---|
321 if (**p == '#') | 321 if (**p == '#') |
322 { | 322 { |
323 lw_expr_t e; | 323 lw_expr_t e; |
324 | 324 |
325 (*p)++; | 325 (*p)++; |
326 as -> exprwidth = 8; | |
326 e = lwasm_parse_expr(as, p); | 327 e = lwasm_parse_expr(as, p); |
328 as -> exprwidth = 16; | |
327 if (!e) | 329 if (!e) |
328 { | 330 { |
329 lwasm_register_error(as, l, "Bad operand"); | 331 lwasm_register_error(as, l, "Bad operand"); |
330 return; | 332 return; |
331 } | 333 } |
515 | 517 |
516 if (**p == '#') | 518 if (**p == '#') |
517 { | 519 { |
518 (*p)++; | 520 (*p)++; |
519 | 521 |
522 as -> exprwidth = 8; | |
520 e = lwasm_parse_expr(as, p); | 523 e = lwasm_parse_expr(as, p); |
524 as -> exprwidth = 16; | |
521 if (!e) | 525 if (!e) |
522 { | 526 { |
523 lwasm_register_error(as, l, "Bad operand"); | 527 lwasm_register_error(as, l, "Bad operand"); |
524 return; | 528 return; |
525 } | 529 } |