diff 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
line wrap: on
line diff
--- a/lwasm/insn_gen.c	Tue Jun 02 20:08:58 2015 -0600
+++ b/lwasm/insn_gen.c	Tue Jun 02 20:58:14 2015 -0600
@@ -323,7 +323,9 @@
 		lw_expr_t e;
 		
 		(*p)++;
+		as -> exprwidth = 8;
 		e = lwasm_parse_expr(as, p);
+		as -> exprwidth = 16;
 		if (!e)
 		{
 			lwasm_register_error(as, l, "Bad operand");
@@ -517,7 +519,9 @@
 	{
 		(*p)++;
 
+		as -> exprwidth = 8;
 		e = lwasm_parse_expr(as, p);
+		as -> exprwidth = 16;
 		if (!e)
 		{
 			lwasm_register_error(as, l, "Bad operand");