Mercurial > hg-old > index.cgi
view lwasm/pass1.c @ 337:04c80c51b16a
Checkpoint development
author | lost |
---|---|
date | Fri, 12 Mar 2010 06:01:38 +0000 |
parents | 67224d8d1024 |
children | 1a6fc6ebb31c |
line wrap: on
line source
/* pass1.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 <lw_alloc.h> #include "lwasm.h" #include "input.h" /* pass 1: parse the lines */ void do_pass1(asmstate_t *as) { char *line; line_t *cl; for (;;) { line = input_readline(as); if (!line) break; printf("%s\n", line); cl = lw_alloc(sizeof(line_t)); cl -> next = NULL; cl -> prev = as -> line_tail; cl -> len = -1; cl -> insn = -1; if (!as -> line_tail) { as -> line_head = cl; cl -> addr = lw_expr_build(lw_expr_type_int, 0); } else { lw_expr_t te; as -> line_tail -> next = cl; te = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, cl -> prev); cl -> addr = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, cl -> prev -> addr, te); lw_expr_destroy(te); lw_expr_simplify(cl -> addr); } as -> line_tail = cl; lw_expr_print(cl -> addr); printf("\n"); // now parse the line lw_free(line); } }