diff 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
line wrap: on
line diff
--- a/lwasm/lwasm.c	Tue Jun 02 20:08:58 2015 -0600
+++ b/lwasm/lwasm.c	Tue Jun 02 20:58:14 2015 -0600
@@ -732,9 +732,17 @@
 lw_expr_t lwasm_parse_expr(asmstate_t *as, char **p)
 {
 	lw_expr_t e;
-	
-	e = lw_expr_parse(p, as);
-	
+
+	if (as->exprwidth != 16)	
+	{
+		lw_expr_setwidth(as->exprwidth);
+		e = lw_expr_parse(p, as);
+		lw_expr_setwidth(0);
+	}
+	else
+	{
+		e = lw_expr_parse(p, as);
+	}
 	return e;
 }