# HG changeset patch
# User lost@starbug
# Date 1270611309 21600
# Node ID 0b5a26bedbe16443d0d16828c07cb34986eecb84
# Parent d96c30e60ddff0661d6b7d3440df2683147503b9
Pass framework simplified; skeleton pass 3
diff -r d96c30e60ddf -r 0b5a26bedbe1 lwasm/Makefile.am
--- a/lwasm/Makefile.am Tue Apr 06 21:03:19 2010 -0600
+++ b/lwasm/Makefile.am Tue Apr 06 21:35:09 2010 -0600
@@ -1,7 +1,7 @@
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_builddir)/lwlib -I$(top_srcdir)/lwlib
bin_PROGRAMS = lwasm
lwasm_SOURCES = main.c pragma.c input.c pass1.c lwasm.c \
- instab.c symbol.c macro.c pass2.c \
+ instab.c symbol.c macro.c pass2.c pass3.c \
insn_inh.c insn_rtor.c insn_tfm.c insn_rlist.c insn_rel.c \
insn_bitbit.c insn_indexed.c insn_gen.c insn_logicmem.c \
pseudo.c section.c os9.c
diff -r d96c30e60ddf -r 0b5a26bedbe1 lwasm/main.c
--- a/lwasm/main.c Tue Apr 06 21:03:19 2010 -0600
+++ b/lwasm/main.c Tue Apr 06 21:35:09 2010 -0600
@@ -166,11 +166,26 @@
*/
extern void do_pass1(asmstate_t *as);
extern void do_pass2(asmstate_t *as);
+extern void do_pass3(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);
+
+struct passlist_s
+{
+ char *passname;
+ void (*fn)(asmstate_t *as);
+} passlist[] = {
+ { "parse", do_pass1 },
+ { "symcheck", do_pass2 },
+ { "resolve1", do_pass3 },
+ { NULL, NULL }
+};
+
int main(int argc, char **argv)
{
+ int passnum;
+
/* assembler state */
asmstate_t asmstate = { 0 };
program_name = argv[0];
@@ -193,13 +208,15 @@
input_init(&asmstate);
- do_pass1(&asmstate);
- if (asmstate.errorcount > 0)
+ for (passnum = 0; passlist[passnum].fn; passnum++)
{
- lwasm_show_errors(&asmstate);
- exit(1);
+ fprintf(stderr, "Doing pass %d (%s)\n", passnum, passlist[passnum].passname);
+ (passlist[passnum].fn)(&asmstate);
+
+ if (asmstate.errorcount > 0)
+ {
+ lwasm_show_errors(&asmstate);
+ exit(1);
+ }
}
- do_pass2(&asmstate);
-
- exit(0);
}
diff -r d96c30e60ddf -r 0b5a26bedbe1 lwasm/pass3.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lwasm/pass3.c Tue Apr 06 21:35:09 2010 -0600
@@ -0,0 +1,42 @@
+/*
+pass3.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"
+
+/*
+Resolve1 Pass
+
+repeatedly resolve instruction sizes and line addresses
+until nothing more reduces
+
+*/
+void do_pass3(asmstate_t *as)
+{
+}