Mercurial > hg > index.cgi
comparison lwasm/insn_gen.c @ 355:3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
8 bit immediate operands should flag a byte overflow if they are out of
range. The acceptable range is -128 <= x <= 255 to cover both signed and
unsigned values.
author | William Astle <lost@l-w.ca> |
---|---|
date | Tue, 19 May 2015 12:26:35 -0600 |
parents | 210d261a614d |
children | 433dbc18fb41 |
comparison
equal
deleted
inserted
replaced
354:433851a26794 | 355:3afb809c7add |
---|---|
367 { | 367 { |
368 if (l -> lint2 == 3) | 368 if (l -> lint2 == 3) |
369 { | 369 { |
370 lw_expr_t e; | 370 lw_expr_t e; |
371 e = lwasm_fetch_expr(l, 0); | 371 e = lwasm_fetch_expr(l, 0); |
372 if (lw_expr_istype(e, lw_expr_type_int)) | |
373 { | |
374 int i; | |
375 i = lw_expr_intval(e); | |
376 if (i < -128 || i > 255) | |
377 { | |
378 lwasm_register_error(as, l, "Byte overflow"); | |
379 } | |
380 } | |
381 | |
372 lwasm_emitop(l, instab[l -> insn].ops[3]); | 382 lwasm_emitop(l, instab[l -> insn].ops[3]); |
373 lwasm_emitexpr(l, e, 1); | 383 lwasm_emitexpr(l, e, 1); |
374 return; | 384 return; |
375 } | 385 } |
376 | 386 |
526 { | 536 { |
527 lw_expr_t e; | 537 lw_expr_t e; |
528 | 538 |
529 lwasm_emitop(l, instab[l -> insn].ops[0]); | 539 lwasm_emitop(l, instab[l -> insn].ops[0]); |
530 e = lwasm_fetch_expr(l, 0); | 540 e = lwasm_fetch_expr(l, 0); |
541 if (lw_expr_istype(e, lw_expr_type_int)) | |
542 { | |
543 int i; | |
544 i = lw_expr_intval(e); | |
545 if (i < -128 || i > 255) | |
546 { | |
547 lwasm_register_error(as, l, "Byte overflow"); | |
548 } | |
549 } | |
531 lwasm_emitexpr(l, e, 1); | 550 lwasm_emitexpr(l, e, 1); |
532 } | 551 } |