diff lwasm/main.c @ 365:3f8abaac214c

Add map file output and option to suppress local symbols in listings Add --map option to generate a symbol map in a regular format that can be used as an import for other tools. Also add --symbols-nolocals to suppress output of local symbols in the symbol listing. In other words, only global symbols are listed. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Tue, 02 Jun 2015 20:08:58 -0600
parents 5d401d1eb3e9
children 433dbc18fb41
line wrap: on
line diff
--- a/lwasm/main.c	Mon Jun 01 19:55:11 2015 -0600
+++ b/lwasm/main.c	Tue Jun 02 20:08:58 2015 -0600
@@ -47,6 +47,8 @@
 	{ "format",		'f',	"TYPE",		0,							"Select output format: decb, raw, obj, os9"},
 	{ "list",		'l',	"FILE",		lw_cmdline_opt_optional,	"Generate list [to FILE]"},
 	{ "symbols",	's',	0,			lw_cmdline_opt_optional,	"Generate symbol list in listing, no effect without --list"},
+	{ "symbols-nolocals", 0x103,	0,	lw_cmdline_opt_optional,	"Same as --symbols but with local labels ignored"},
+	{ "map",		'm',	"FILE",		lw_cmdline_opt_optional,	"Generate map [to FILE]"},
 	{ "decb",		'b',	0,			0,							"Generate DECB .bin format output, equivalent of --format=decb"},
 	{ "raw",		'r',	0,			0,							"Generate raw binary format output, equivalent of --format=raw"},
 	{ "obj",		0x100,	0,			0,							"Generate proprietary object file format for later linking, equivalent of --format=obj" },
@@ -122,10 +124,24 @@
 		as -> flags |= FLAG_LIST;
 		break;
 
+	case 'm':
+		if (as -> map_file)
+			lw_free(as -> map_file);
+		if (!arg)
+			as -> map_file = lw_strdup("-");
+		else
+			as -> map_file = lw_strdup(arg);
+		as -> flags |= FLAG_MAP;
+		break;
+
 	case 's':
 		as -> flags |= FLAG_SYMBOLS;
 		break;
-		
+
+	case 0x103:
+		as -> flags |= FLAG_SYMBOLS | FLAG_SYMBOLS_NOLOCALS;
+		break;
+
 	case 'b':
 		as -> output_format = OUTPUT_DECB;
 		break;
@@ -236,6 +252,7 @@
 extern void do_pass7(asmstate_t *as);
 extern void do_output(asmstate_t *as);
 extern void do_list(asmstate_t *as);
+extern void do_map(asmstate_t *as);
 extern lw_expr_t lwasm_evaluate_special(int t, void *ptr, void *priv);
 extern lw_expr_t lwasm_evaluate_var(char *var, void *priv);
 extern lw_expr_t lwasm_parse_term(char **p, void *priv);
@@ -343,5 +360,6 @@
 		lwasm_do_unicorns(&asmstate);
 	}
 	do_list(&asmstate);
+	do_map(&asmstate);
 	exit(0);
 }