annotate old-trunk/lwasm/old/pass2.c @ 348:11a95c6414b4

Added third func to instab to split resolve and emit logic
author lost@starbug
date Sat, 27 Mar 2010 22:15:07 -0600
parents eb230fa7d28e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
1 /*
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
2 pass2.c
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
3 Copyright © 2009 William Astle
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
4
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
5 This file is part of LWASM.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
6
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
10 version.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
11
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
15 more details.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
16
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
19
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
20
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
21 Handles second pass of assembly
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
22
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
23 */
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
24
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
25 #include <config.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
26
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
27 #include "lwasm.h"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
28
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
29 void lwasm_pass2(asmstate_t *as)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
30 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
31 lwasm_line_t *l;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
32 sectiontab_t *st;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
33
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
34 debug_message(1, "Entering pass 2");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
35 as -> passnum = 2;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
36 as -> addr = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
37 as -> context = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
38 as -> endseen = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
39 as -> skipcond = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
40 as -> skipcount = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
41 as -> skipmacro = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
42 as -> inmacro = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
43 as -> nextcontext = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
44 as -> skiplines = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
45 as -> dpval = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
46 as -> inmod = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
47
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
48 for (st = as -> sections; st; st = st -> next)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
49 st -> offset = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
50 as -> csect = NULL;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
51
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
52 // iterate over all the lines and re-parse them
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
53 for (l = as -> lineshead; l && !(as -> endseen); l = l -> next)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
54 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
55 if (as -> skiplines)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
56 as -> skiplines--;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
57 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
58 lwasm_parse_line(as, l);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
59 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
60 }