diff lwasm/parse.c @ 190:563adfccb645

Added 'sym=expr' opcode handling
author lost
date Sun, 22 Mar 2009 16:08:20 +0000
parents 99300be2d3bd
children bae1e3ecdce1
line wrap: on
line diff
--- a/lwasm/parse.c	Sun Mar 22 06:52:06 2009 +0000
+++ b/lwasm/parse.c	Sun Mar 22 16:08:20 2009 +0000
@@ -111,6 +111,25 @@
 	memcpy(opc, p, p2 - p);
 	opc[p2 - p] = '\0';
 
+	l -> forceglobal = 0;
+	// if the opcode contains an =, treat it as "symbol = expr"
+	if (!sym && strchr(opc, '='))
+	{
+		for (p2 = opc; *p2 && *p2 != '='; p2++)
+			/* do nothing */ ;
+		sym = lwasm_alloc((p2 - opc) + 1);
+		memcpy(sym, opc, p2 - opc);
+		sym[p2 - opc] = '\0';
+		l -> sym = sym;
+		
+		p2 = p + (p2 - opc) + 1;
+//		p2++;
+		opc[0] = '=';
+		opc[1] = '\0';
+		debug_message(2, "Found opcode = with symbol %s and operand %s", sym, p2);
+		l -> forceglobal = 1;
+	}
+	
 	debug_message(2, "Found operation code: '%s'", opc);
 
 	// skip intervening whitespace if present