changeset 458:3948c874901b

Make offset,R operand size warning work properly Make the offset,R operand size check warning work for non-lea operations. Also exclude offset,W from the check since there is no 8 bit offset.
author William Astle <lost@l-w.ca>
date Sat, 17 Feb 2018 00:13:46 -0700
parents 7d6eacd87370
children ed7b8f74087d a6c9129e5948
files lwasm/insn_gen.c lwasm/insn_indexed.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/insn_gen.c	Fri Feb 16 23:40:53 2018 -0700
+++ b/lwasm/insn_gen.c	Sat Feb 17 00:13:46 2018 -0700
@@ -288,6 +288,17 @@
 				if (i < -128 || i > 127)
 					lwasm_register_error(as, l, E_BYTE_OVERFLOW);
 			}
+			else if (l -> lint == 2 && lw_expr_istype(e, lw_expr_type_int) && CURPRAGMA(l, PRAGMA_OPERANDSIZE))
+			{
+				if (l -> pb != 0xAF && l -> pb != 0xB0)
+				{
+					if ((i >= -128 && i <= 127) || i >= 0xFF80)
+					{
+						lwasm_register_error(as, l, W_OPERAND_SIZE);
+
+					}
+				}
+			}
 			lwasm_emitexpr(l, e, l -> lint);
 		}
 
--- a/lwasm/insn_indexed.c	Fri Feb 16 23:40:53 2018 -0700
+++ b/lwasm/insn_indexed.c	Sat Feb 17 00:13:46 2018 -0700
@@ -709,7 +709,8 @@
 		}
 	}
 	
-	if (l -> lint == 2 && CURPRAGMA(l, PRAGMA_OPERANDSIZE))
+	// exclude expr,W since that can only be 16 bits
+	if (l -> lint == 2 && CURPRAGMA(l, PRAGMA_OPERANDSIZE) && (l -> pb != 0xAF && l -> pb != 0xB0))
 	{
 		int offs;
 		e = lwasm_fetch_expr(l, 0);