# HG changeset patch
# User lost@starbug
# Date 1273977964 21600
# Node ID 38b50ce6967ad43e41a55c556684df248fd1276d
# Parent 848d3cca8078e05767b30f6d024474bf1bd37f73
Made --list and --depend work
diff -r 848d3cca8078 -r 38b50ce6967a lwasm/input.c
--- a/lwasm/input.c Sat May 15 20:01:58 2010 -0600
+++ b/lwasm/input.c Sat May 15 20:46:04 2010 -0600
@@ -67,6 +67,7 @@
if (as -> file_dir)
lw_stack_destroy(as -> file_dir);
as -> file_dir = lw_stack_create(lw_free);
+ as -> includelist = lw_stack_create(lw_free);
lw_stringlist_reset(as -> input_files);
while (IS)
{
@@ -80,9 +81,14 @@
{
/* take apart fn into path and filename then push the path */
/* onto the current file path stack */
+
+ /* also add it to the list of files included */
char *dn, *dp;
int o;
-
+
+ dn = lw_strdup(fn);
+ lw_stack_push(as -> includelist, dn);
+
dn = lw_strdup(fn);
dp = dn + strlen(dn);
diff -r 848d3cca8078 -r 38b50ce6967a lwasm/list.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lwasm/list.c Sat May 15 20:46:04 2010 -0600
@@ -0,0 +1,89 @@
+/*
+list.c
+
+Copyright © 2010 William Astle
+
+This file is part of LWTOOLS.
+
+LWTOOLS is free software: you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see .
+*/
+
+#include
+
+#include
+#include
+
+#include
+#include
+
+#include "lwasm.h"
+#include "instab.h"
+
+/*
+Do listing
+*/
+void do_list(asmstate_t *as)
+{
+ line_t *cl;
+ FILE *of;
+ int i;
+
+ if (!(as -> flags & FLAG_LIST))
+ return;
+
+ if (as -> list_file)
+ of = fopen(as -> list_file, "w");
+ else
+ of = stdout;
+ if (!of)
+ {
+ fprintf(stderr, "Cannot open list file; list not generated\n");
+ return;
+ }
+ for (cl = as -> line_head; cl; cl = cl -> next)
+ {
+ if (cl -> len < 1)
+ {
+ fprintf(of, " ");
+ }
+ else
+ {
+ fprintf(of, "%04X ", lw_expr_intval(cl -> addr));
+ for (i = 0; i < cl -> outputl && i < 8; i++)
+ {
+ fprintf(of, "%02X", cl -> output[i]);
+ }
+ for (; i < 8; i++)
+ {
+ fprintf(of, " ");
+ }
+ fprintf(of, " ");
+ }
+ fprintf(of, "%15s:%05d %s\n", cl -> linespec, cl -> lineno, cl -> ltext);
+ if (cl -> outputl > 8)
+ {
+ for (i = 8; i < cl -> outputl; i++)
+ {
+ if (i % 8 == 0)
+ {
+ if (i != 8)
+ fprintf(of, "\n ");
+ else
+ fprintf(of, " ");
+ }
+ fprintf(of, "%02X", cl -> output[i]);
+ }
+ }
+ }
+}
diff -r 848d3cca8078 -r 38b50ce6967a lwasm/lwasm.h
--- a/lwasm/lwasm.h Sat May 15 20:01:58 2010 -0600
+++ b/lwasm/lwasm.h Sat May 15 20:46:04 2010 -0600
@@ -238,6 +238,7 @@
void *input_data; // opaque data used by the input system
lw_stringlist_t include_list; // include paths
lw_stack_t file_dir; // stack of the "current file" dir
+ lw_stack_t includelist;
int exportcheck; // set if we need to collapse out the section base to 0
};
diff -r 848d3cca8078 -r 38b50ce6967a lwasm/main.c
--- a/lwasm/main.c Sat May 15 20:01:58 2010 -0600
+++ b/lwasm/main.c Sat May 15 20:46:04 2010 -0600
@@ -236,9 +236,23 @@
exit(1);
}
}
-
- debug_message(&asmstate, 50, "Doing output");
- do_output(&asmstate);
+
+ if (asmstate.flags & FLAG_DEPEND)
+ {
+ // output dependencies
+ char *n;
+
+ while (n = lw_stack_pop(asmstate.includelist))
+ {
+ fprintf(stdout, "%s\n", n);
+ lw_free(n);
+ }
+ }
+ else
+ {
+ debug_message(&asmstate, 50, "Doing output");
+ do_output(&asmstate);
+ }
debug_message(&asmstate, 50, "Done assembly");