comparison lwasm/insn_indexed.c @ 466:51bed8c8dc53

Actually check if we resolved a PCR reference before assuming 8 bits You actually need to check if an expression collapsed to an integer before assuming it is one. Otherwise, you end up assuming everything is 8 bit offsets. Oops.
author William Astle <lost@l-w.ca>
date Wed, 28 Feb 2018 23:35:12 -0700
parents 7370a67caf7e
children 9393a6b8886c
comparison
equal deleted inserted replaced
465:7370a67caf7e 466:51bed8c8dc53
586 // bit boundary conditions. 586 // bit boundary conditions.
587 v = as -> pretendmax; 587 v = as -> pretendmax;
588 as -> pretendmax = 1; 588 as -> pretendmax = 1;
589 lwasm_reduce_expr(as, e2); 589 lwasm_reduce_expr(as, e2);
590 as -> pretendmax = v; 590 as -> pretendmax = v;
591 v = lw_expr_intval(e2); 591 if (lw_expr_istype(e2, lw_expr_type_int))
592 // Actual range is -128 <= offset <= 127; we're allowing a fudge 592 {
593 // factor of 25 or so bytes so that we're less likely to accidentally 593 v = lw_expr_intval(e2);
594 // cross into the 16 bit boundary in weird corner cases. 594 // Actual range is -128 <= offset <= 127; we're allowing a fudge
595 if (v >= -100 || v <= 100) 595 // factor of 25 or so bytes so that we're less likely to accidentally
596 { 596 // cross into the 16 bit boundary in weird corner cases.
597 l -> lint = 1; 597 if (v >= -100 || v <= 100)
598 l -> pb = (l -> pb & 0x80) ? 0x9C : 0x8C; 598 {
599 return; 599 l -> lint = 1;
600 l -> pb = (l -> pb & 0x80) ? 0x9C : 0x8C;
601 return;
602 }
600 } 603 }
601 } 604 }
602 } 605 }
603 lw_expr_destroy(e2); 606 lw_expr_destroy(e2);
604 } 607 }