Mercurial > hg-old > index.cgi
changeset 368:656630007668
Emit pass
author | lost@starbug |
---|---|
date | Thu, 15 Apr 2010 22:18:48 -0600 |
parents | 34dfc9747f23 |
children | 898a41f7eb59 |
files | doc/internals.txt lwasm/Makefile.am lwasm/main.c lwasm/pass7.c |
diffstat | 4 files changed, 61 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- 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
--- 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 } };
--- /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 <http://www.gnu.org/licenses/>. +*/ + +#include <config.h> + +#include <stdio.h> +#include <string.h> + +#include <lw_alloc.h> +#include <lw_string.h> + +#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); + } + } + } +}