changeset 158:f0527dc3804d

Added support for .globl <sym>, .area <section>, .word, .byte, .blkb, and a .module directive that does nothing
author lost
date Sat, 31 Jan 2009 05:30:06 +0000
parents 745721e13970
children 71561c12b20b
files lwasm/instab.c lwasm/pseudo.c
diffstat 2 files changed, 43 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/instab.c	Sat Jan 31 05:29:15 2009 +0000
+++ b/lwasm/instab.c	Sat Jan 31 05:30:06 2009 +0000
@@ -79,6 +79,7 @@
 extern OPFUNC(pseudo_export);
 extern OPFUNC(pseudo_ifdef);
 extern OPFUNC(pseudo_ifndef);
+extern OPFUNC(pseudo_noop);
 
 instab_t instab[] =
 {
@@ -382,7 +383,19 @@
 	
 	{ "pragma",	{ -1, -1, -1, -1},	pseudo_pragma },
 	{ "*pragma",	{ -1, -1, -1, -1},	pseudo_starpragma },
+
+	/* for compatibility with gcc6809 output... */
+	{ ".area",	{ -1, -1, -1, -1},	pseudo_section },
+	{ ".globl",	{ -1, -1, -1, -1}, 	pseudo_export },
+	{ ".module",	{ -1, -1, -1, -1},	pseudo_noop },
 	
+	{ ".word",	{ -1, -1, -1, -1},	pseudo_fdb },
+	{ ".byte",	{ -1, -1, -1, -1},	pseudo_fcb },
+	
+	{ ".blkb",	{ -1, -1, -1, -1},	pseudo_rmb },
+
+// needs to handle C escapes maybe?
+//	{ ".ascii",	{ -1, -1, -1, -1},	pseudo_ascii },
 
 	/* flag end of table */	
 	{ NULL,		{ -0x1, -0x1, -0x1, -0x1 }, insn_inh }
--- a/lwasm/pseudo.c	Sat Jan 31 05:29:15 2009 +0000
+++ b/lwasm/pseudo.c	Sat Jan 31 05:30:06 2009 +0000
@@ -30,6 +30,11 @@
 
 extern int lwasm_read_file(asmstate_t *as, const char *filename);
 
+OPFUNC(pseudo_noop)
+{
+
+}
+
 OPFUNC(pseudo_org)
 {
 	int v, r;
@@ -908,16 +913,39 @@
 {
 	lwasm_symbol_ent_t *se;
 	export_list_t *ex;
-	
+	char *sym2, *sym3;
+
 	if (as -> outformat != OUTPUT_OBJ)
 	{
 		register_error(as, l, 1, "Symbol exports only supported for obj target");
 		return;
 	}
-	
+
 	if (as -> passnum == 1)
 		return;
 
+	if (!(l -> sym))
+	{
+		// look for symbol after op
+		if (**p)
+		{
+			for (sym2 = *p; **p && !isspace(**p); (*p)++)
+				/* do nothing */
+			sym3 = lwasm_alloc(*p - sym2 + 1);
+			memcpy(sym3, sym2, *p - sym2);
+			sym3[*p - sym2] = '\0';
+			
+			l -> sym = sym3;
+		}
+	}
+
+	if (!(l -> sym))
+	{
+		register_error(as, l, 2, "No symbol");
+		return;
+	}
+
+
 	// the symbol better be defined at this point (pass 2)
 	// local symbols cannot be exported nor can "global" symbols
 	se = lwasm_find_symbol(as, l -> sym, -1);