changeset 385:cf8c92d70eb1

Various bugfixes
author lost@starbug
date Sun, 16 May 2010 11:50:00 -0600
parents 38b50ce6967a
children af5f2c51db76
files lwasm/lwasm.c lwasm/main.c lwasm/pass1.c lwasm/section.c
diffstat 4 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/lwasm.c	Sat May 15 20:46:04 2010 -0600
+++ b/lwasm/lwasm.c	Sun May 16 11:50:00 2010 -0600
@@ -99,8 +99,9 @@
 	{
 	case lwasm_expr_secbase:
 		{
-			line_t *cl = ptr;
-			if (cl -> as -> exportcheck && ptr == cl -> as -> csect)
+//			sectiontab_t *s = priv;
+			asmstate_t *as = priv;
+			if (as -> exportcheck && ptr == as -> csect)
 				return lw_expr_build(lw_expr_type_int, 0);
 			return NULL;
 		}
--- a/lwasm/main.c	Sat May 15 20:46:04 2010 -0600
+++ b/lwasm/main.c	Sun May 16 11:50:00 2010 -0600
@@ -184,8 +184,9 @@
 {
 	char *passname;
 	void (*fn)(asmstate_t *as);
+	int fordep;
 } passlist[] = {
-	{ "parse", do_pass1 },
+	{ "parse", do_pass1, 1 },
 	{ "symcheck", do_pass2 },
 	{ "resolve1", do_pass3 },
 	{ "resolve2", do_pass4 },
@@ -225,6 +226,8 @@
 
 	for (passnum = 0; passlist[passnum].fn; passnum++)
 	{
+		if ((asmstate.flags & FLAG_DEPEND) && passlist[passnum].fordep == 0)
+			continue;
 		debug_message(&asmstate, 50, "Doing pass %d (%s)\n", passnum, passlist[passnum].passname);
 		(passlist[passnum].fn)(&asmstate);
 		debug_message(&asmstate, 50, "After pass %d (%s)\n", passnum, passlist[passnum].passname);
--- a/lwasm/pass1.c	Sat May 15 20:46:04 2010 -0600
+++ b/lwasm/pass1.c	Sun May 16 11:50:00 2010 -0600
@@ -91,6 +91,7 @@
 		cl -> pragmas = as -> pragmas;
 		cl -> context = as -> context;
 		cl -> ltext = lw_strdup(line);
+		as -> cl = cl;
 		if (!as -> line_tail)
 		{
 			as -> line_head = cl;
@@ -107,7 +108,8 @@
 			te = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, cl -> prev);
 			cl -> addr = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, cl -> prev -> addr, te);
 			lw_expr_destroy(te);
-			lw_expr_simplify(cl -> addr, as);
+			lwasm_reduce_expr(as, cl -> addr);
+//			lw_expr_simplify(cl -> addr, as);
 
 			// carry DP value forward
 			cl -> dpval = cl -> prev -> dpval;
@@ -121,7 +123,6 @@
 			lc = 0;
 		}
 		as -> line_tail = cl;
-		as -> cl = cl;
 		// blank lines don't count for anything
 		// except a local symbol context break
 		if (!*line)
--- a/lwasm/section.c	Sat May 15 20:46:04 2010 -0600
+++ b/lwasm/section.c	Sun May 16 11:50:00 2010 -0600
@@ -173,7 +173,10 @@
 	}
 	
 	if (l -> sym)
+	{
 		sym = lw_strdup(l -> sym);
+		l -> symset = 1;
+	}
 	
 	if (l -> sym)
 	{
@@ -190,6 +193,7 @@
 			/* do nothing */ ;
 		
 		sym = lw_strndup(*p, p2 - *p);
+		*p = p2;
 	}
 	if (!sym)
 	{
@@ -229,7 +233,10 @@
 	}
 	
 	if (l -> sym)
+	{
 		sym = lw_strdup(l -> sym);
+		l -> symset = 1;
+	}
 	
 	if (l -> sym)
 	{
@@ -246,6 +253,7 @@
 			/* do nothing */ ;
 		
 		sym = lw_strndup(*p, p2 - *p);
+		*p = p2;
 	}
 	if (!sym)
 	{