annotate lwasm/pass2.c @ 255:6363b9ebf825 2.x

Support files with line numbers in lwasm
author lost
date Sun, 20 Dec 2009 05:40:47 +0000
parents c7a41b4c89b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
1 /*
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
2 pass2.c
43
b33eca135258 Added second pass code generation
lost
parents: 13
diff changeset
3 Copyright © 2009 William Astle
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
4
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
5 This file is part of LWASM.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
6
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
10 version.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
11
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
15 more details.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
16
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
19
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
20
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
21 Handles second pass of assembly
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
22
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
23 */
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
24
212
bae1e3ecdce1 More preparation for gnulib integration
lost
parents: 151
diff changeset
25 #include <config.h>
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
26
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
27 #include "lwasm.h"
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
28
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
29 void lwasm_pass2(asmstate_t *as)
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
30 {
43
b33eca135258 Added second pass code generation
lost
parents: 13
diff changeset
31 lwasm_line_t *l;
74
c8c772ef5df9 Checkpointing object target implementation
lost
parents: 65
diff changeset
32 sectiontab_t *st;
c8c772ef5df9 Checkpointing object target implementation
lost
parents: 65
diff changeset
33
44
2330b88f9600 Added simple output listing
lost
parents: 43
diff changeset
34 debug_message(1, "Entering pass 2");
43
b33eca135258 Added second pass code generation
lost
parents: 13
diff changeset
35 as -> passnum = 2;
b33eca135258 Added second pass code generation
lost
parents: 13
diff changeset
36 as -> addr = 0;
51
04868fa52a15 Fixed context counting for second pass so local symbols work correctly
lost
parents: 44
diff changeset
37 as -> context = 0;
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 51
diff changeset
38 as -> endseen = 0;
57
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
39 as -> skipcond = 0;
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
40 as -> skipcount = 0;
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
41 as -> skipmacro = 0;
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
42 as -> inmacro = 0;
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
43 as -> nextcontext = 1;
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
44 as -> skiplines = 0;
65
31d8e85706e7 Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents: 58
diff changeset
45 as -> dpval = 0;
236
a58f49a77441 Added os9 target, pragma to control whether $ localizes a symbol, and fixed some condition nesting bugs
lost
parents: 212
diff changeset
46 as -> inmod = 0;
254
c7a41b4c89b3 Added struct support to LWASM
lost
parents: 236
diff changeset
47 as -> instruct = 0;
65
31d8e85706e7 Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents: 58
diff changeset
48
74
c8c772ef5df9 Checkpointing object target implementation
lost
parents: 65
diff changeset
49 for (st = as -> sections; st; st = st -> next)
c8c772ef5df9 Checkpointing object target implementation
lost
parents: 65
diff changeset
50 st -> offset = 0;
c8c772ef5df9 Checkpointing object target implementation
lost
parents: 65
diff changeset
51 as -> csect = NULL;
c8c772ef5df9 Checkpointing object target implementation
lost
parents: 65
diff changeset
52
43
b33eca135258 Added second pass code generation
lost
parents: 13
diff changeset
53 // iterate over all the lines and re-parse them
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 51
diff changeset
54 for (l = as -> lineshead; l && !(as -> endseen); l = l -> next)
57
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
55 {
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
56 if (as -> skiplines)
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
57 as -> skiplines--;
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
58 else
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
59 lwasm_parse_line(as, l);
035b95a3690f Added conditional assembly and macros
lost
parents: 54
diff changeset
60 }
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
61 }