diff src/pseudo.c @ 64:aaddd47219b4

Added the 'set' directive
author lost
date Mon, 05 Jan 2009 01:27:08 +0000
parents d85ba47b1e8f
children 31d8e85706e7
line wrap: on
line diff
--- a/src/pseudo.c	Mon Jan 05 01:17:23 2009 +0000
+++ b/src/pseudo.c	Mon Jan 05 01:27:08 2009 +0000
@@ -372,45 +372,31 @@
 	l -> symaddr = rval & 0xFFFF;
 	l -> addrset = 2;
 	
-	lwasm_register_symbol(as, l, l -> sym, rval);
+	lwasm_register_symbol(as, l, l -> sym, rval, SYMBOL_NORM);
 }
 
 OPFUNC(pseudo_set)
 {
+	int rval;
+
+	// set MUST run on both passes as the symbol value changes!
+
+	if (l -> sym == NULL)
+	{
+		register_error(as, l, 1, "No symbol specified");
+		return;
+	}
+
+	if (lwasm_expr_result(as, l, p, EXPR_PASS1CONST | EXPR_PASS2CONST, &rval) < 0)
+		rval = 0;
+
+	l -> symaddr = rval & 0xFFFF;
+	l -> addrset = 2;
+	
+	lwasm_register_symbol(as, l, l -> sym, rval, SYMBOL_SET);
 }
 
 /*
-void pseudo_set(asmstate_t *as, sourceline_t *cl, char **optr)
-{
-	int rval, v1;
-	
-	if (cl -> hassym == 0)
-	{
-		errorp1(ERR_NOSYM);
-		return;
-	}
-	rval = eval_expr(as, cl, optr, &v1);
-	// eval_expr returns -1 if there was a forward ref
-	// or -2 if the expr was invalid
-	if (rval == -2)
-	{
-		// carp
-		errorp1(ERR_FORWARD);
-	}
-	if (rval < 0)
-	{
-		// remove symbol ref
-		cl -> hassym = 0;
-		// mark as a "comment" so it isn't processed next time
-		cl -> opcode = -1;
-		return;
-	}
-	cl -> code_symloc = v1;
-	cl -> isset = 1;
-	cl -> isequ = 1;
-	cl -> symaddr = v1 & 0xFFFF;
-}
-
 void pseudo_setdp(asmstate_t *as, sourceline_t *cl, char **optr)
 {
 	int rval, v1;