# HG changeset patch # User lost@starbug # Date 1271391528 21600 # Node ID 656630007668f9c283e4cf430c0372f9ba0f016f # Parent 34dfc9747f234742c5cdabf5c0019d6dac7cda3c Emit pass diff -r 34dfc9747f23 -r 656630007668 doc/internals.txt --- a/doc/internals.txt Thu Apr 15 21:56:06 2010 -0600 +++ b/doc/internals.txt Thu Apr 15 22:18:48 2010 -0600 @@ -50,3 +50,8 @@ all expressions must resolve to a constant. For the object form, all expressions must resolve to symbol references and constants. Those symbol references may be internal or external. + +Pass 7 +------ + +Emit object code for each line for later output. diff -r 34dfc9747f23 -r 656630007668 lwasm/Makefile.am --- a/lwasm/Makefile.am Thu Apr 15 21:56:06 2010 -0600 +++ b/lwasm/Makefile.am Thu Apr 15 22:18:48 2010 -0600 @@ -4,6 +4,6 @@ instab.c symbol.c macro.c pass2.c pass3.c pass4.c pass5.c pass6.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 + pseudo.c section.c os9.c pass7.c lwasm_LDADD = -L$(top_builddir)/lib -L$(top_srcdir)/lib -L$(top_builddir)/lwlib -L$(top_srcdir)/lwlib -lgnu -llw EXTRA_DIST = lwasm.h input.h instab.h diff -r 34dfc9747f23 -r 656630007668 lwasm/main.c --- a/lwasm/main.c Thu Apr 15 21:56:06 2010 -0600 +++ b/lwasm/main.c Thu Apr 15 22:18:48 2010 -0600 @@ -170,6 +170,7 @@ extern void do_pass4(asmstate_t *as); extern void do_pass5(asmstate_t *as); extern void do_pass6(asmstate_t *as); +extern void do_pass7(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); @@ -185,6 +186,7 @@ { "resolve2", do_pass4 }, { "addressresolve", do_pass5 }, { "finalize", do_pass6 }, + { "emit", do_pass7 }, { NULL, NULL } }; diff -r 34dfc9747f23 -r 656630007668 lwasm/pass7.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwasm/pass7.c Thu Apr 15 22:18:48 2010 -0600 @@ -0,0 +1,53 @@ +/* +pass7.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" + +/* +emit pass + +Generate object code +*/ +void do_pass7(asmstate_t *as) +{ + line_t *cl; + + for (cl = as -> line_head; cl; cl = cl -> next) + { + as -> cl = cl; + if (cl -> insn != -1) + { + if (instab[cl -> insn].emit) + { + (instab[cl -> insn].emit)(as, cl); + } + } + } +}