diff lwasm/pass1.c @ 342:7b4123dce741

Added basic symbol registration
author lost@starbug
date Wed, 24 Mar 2010 21:30:31 -0600
parents 1a6fc6ebb31c
children 0215a0fbf61b
line wrap: on
line diff
--- a/lwasm/pass1.c	Fri Mar 19 10:03:56 2010 +0000
+++ b/lwasm/pass1.c	Wed Mar 24 21:30:31 2010 -0600
@@ -24,8 +24,10 @@
 #include <stdio.h>
 
 #include <lw_alloc.h>
+#include <lw_string.h>
 
 #include "lwasm.h"
+#include "instab.h"
 #include "input.h"
 
 /*
@@ -47,7 +49,7 @@
 	char *line;
 	line_t *cl;
 	char *p1;
-	int stpace;
+	int stspace;
 	char *tok, *sym;
 	int opnum;
 	
@@ -120,7 +122,7 @@
 		if (*p1 == '*' || *p1 == ';' || *p1 == '#' || !*p1)
 			goto nextline;
 
-		
+		// find the end of the first token
 		for (tok = p1; *p1 && !isspace(*p1) && *p1 != ':'; p1++)
 			/* do nothing */ ;
 		
@@ -179,7 +181,15 @@
 		
 		if (cl -> sym && cl -> symset == 0)
 		{
+			printf("Register symbol %s:", sym);
+			lw_expr_print(cl -> addr);
+			printf("\n");
+
 			// register symbol at line address
+			if (!register_symbol(as, cl -> sym, cl -> addr, symbol_flag_none))
+			{
+				// symbol error
+			}
 		}
 		
 		lw_expr_print(cl -> addr);