changeset 192:bfd0fb0a85c2

Allow exporting multiple symbols on a single directive
author lost
date Sun, 22 Mar 2009 16:28:40 +0000
parents 29ba546ceea0
children 716879fc6790
files ChangeLog lwasm/pseudo.c
diffstat 2 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Mar 22 16:12:06 2009 +0000
+++ b/ChangeLog	Sun Mar 22 16:28:40 2009 +0000
@@ -23,6 +23,7 @@
 [+] added support for "sym=expr" in the opcode field; this will define a
     global symbol (non-section) if it resolves to a constant
 [+] added operator ~ as a prefix operator for a 1s complement in LWASM
+[+] allow exporting multiple symbols (export sym,sym,sym...)
 [b] arranged for output files for lwasm/lwlink to be removed if the assembly
     or linking fails
 [ ] DECB output of LWLINK now collapses contiguous output blocks into single
--- a/lwasm/pseudo.c	Sun Mar 22 16:12:06 2009 +0000
+++ b/lwasm/pseudo.c	Sun Mar 22 16:28:40 2009 +0000
@@ -1039,6 +1039,7 @@
 	lwasm_symbol_ent_t *se;
 	export_list_t *ex;
 	char *sym2, *sym3;
+	int after = 0;
 
 	if (as -> outformat != OUTPUT_OBJ)
 	{
@@ -1049,18 +1050,26 @@
 	if (as -> passnum == 1)
 		return;
 
-	if (!(l -> sym))
+again:
+	if (!(l -> sym) || after == 1)
 	{
+	
+		after = 1;
 		// look for symbol after op
 		if (**p)
 		{
-			for (sym2 = *p; **p && !isspace(**p); (*p)++)
+			for (sym2 = *p; **p && !isspace(**p) && **p != ','; (*p)++)
 				/* do nothing */ ;
+
+			debug_message(2, "export expression: %s", sym2);			
+			if (l -> sym)
+				lwasm_free(l -> sym);
 			sym3 = lwasm_alloc(*p - sym2 + 1);
 			memcpy(sym3, sym2, *p - sym2);
 			sym3[*p - sym2] = '\0';
 			
 			l -> sym = sym3;
+			debug_message(2, "export symbol: '%s'", sym3);
 		}
 	}
 	if (!(l -> sym))
@@ -1116,4 +1125,15 @@
 	se -> sect -> exports = ex;
 	ex -> offset = se -> value;
 	ex -> sym = lwasm_strdup(se -> sym);
+	if (after == 1)
+	{
+		if (**p == ',')
+		{
+			debug_message(2, "Export another symbol: %s", *p);
+			(*p)++;
+			for ( ; **p && isspace(**p); (*p)++)
+				/* do nothing */ ;
+			goto again;
+		}
+	}
 }