Mercurial > hg > index.cgi
annotate lwasm/list.c @ 106:43a3f1068027
Adjustments for list code
author | lost@l-w.ca |
---|---|
date | Sat, 06 Aug 2011 23:20:45 -0600 |
parents | 428068681cbf |
children | 697bc543368c |
rev | line source |
---|---|
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1 /* |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
2 list.c |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
3 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
4 Copyright © 2010 William Astle |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
5 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
6 This file is part of LWTOOLS. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
7 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
8 LWTOOLS is free software: you can redistribute it and/or modify it under the |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
9 terms of the GNU General Public License as published by the Free Software |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
10 Foundation, either version 3 of the License, or (at your option) any later |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
11 version. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
12 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, but WITHOUT |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
16 more details. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
17 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License along with |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
19 this program. If not, see <http://www.gnu.org/licenses/>. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
20 */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
21 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
22 #include <stdio.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
23 #include <string.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
24 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
25 #include <lw_alloc.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
26 #include <lw_string.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
27 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
28 #include "lwasm.h" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
29 #include "instab.h" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
30 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
31 void list_symbols(asmstate_t *as, FILE *of); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
32 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
33 /* |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
34 Do listing |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
35 */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
36 void do_list(asmstate_t *as) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
37 { |
50 | 38 line_t *cl, *nl, *nl2; |
106 | 39 FILE *of = NULL; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
40 int i; |
50 | 41 unsigned char *obytes = NULL; |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
42 int obytelen = 0; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
43 |
14
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
44 char *tc; |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
45 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
46 if (!(as -> flags & FLAG_LIST)) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
47 return; |
106 | 48 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
49 if (as -> list_file) |
106 | 50 { |
51 if (strcmp(as -> list_file, "-") == 0) | |
52 { | |
53 of = stdout; | |
54 } | |
55 else | |
56 of = fopen(as -> list_file, "w"); | |
57 } | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
58 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
59 of = stdout; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
60 if (!of) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
61 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
62 fprintf(stderr, "Cannot open list file; list not generated\n"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
63 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
64 } |
106 | 65 |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
66 for (cl = as -> line_head; cl; cl = nl) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
67 { |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
68 nl = cl -> next; |
81
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
69 if (CURPRAGMA(cl, PRAGMA_NOLIST)) |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
70 { |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
71 if (cl -> outputl <= 0) |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
72 continue; |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
73 } |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
74 if (cl -> noexpand_start) |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
75 { |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
76 obytelen = 0; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
77 int nc = 0; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
78 for (nl = cl; ; nl = nl -> next) |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
79 { |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
80 if (nl -> noexpand_start) |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
81 nc++; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
82 if (nl -> noexpand_end) |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
83 nc--; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
84 |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
85 if (nl -> outputl > 0) |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
86 obytelen += nl -> outputl; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
87 if (nc == 0) |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
88 break; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
89 } |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
90 obytes = lw_alloc(obytelen); |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
91 nc = 0; |
50 | 92 for (nl2 = cl; ; nl2 = nl2 -> next) |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
93 { |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
94 int i; |
50 | 95 for (i = 0; i < nl2 -> outputl; i++) |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
96 { |
50 | 97 obytes[nc++] = nl2 -> output[i]; |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
98 } |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
99 if (nc >= obytelen) |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
100 break; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
101 } |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
102 nl = nl -> next; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
103 } |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
104 else |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
105 { |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
106 obytelen = cl -> outputl; |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
107 if (obytelen > 0) |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
108 { |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
109 obytes = lw_alloc(obytelen); |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
110 memmove(obytes, cl -> output, cl -> outputl); |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
111 } |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
112 } |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
113 if (cl -> len < 1 && obytelen < 1) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
114 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
115 if (cl -> soff >= 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
116 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
117 fprintf(of, "%04X ", cl -> soff & 0xffff); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
118 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
119 else if (cl -> dshow >= 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
120 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
121 if (cl -> dsize == 1) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
122 { |
42 | 123 fprintf(of, " %02X ", cl -> dshow & 0xff); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
124 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
125 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
126 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
127 fprintf(of, " %04X ", cl -> dshow & 0xff); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
128 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
129 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
130 else if (cl -> dptr) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
131 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
132 lw_expr_t te; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
133 te = lw_expr_copy(cl -> dptr -> value); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
134 as -> exportcheck = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
135 as -> csect = cl -> csect; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
136 lwasm_reduce_expr(as, te); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
137 as -> exportcheck = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
138 if (lw_expr_istype(te, lw_expr_type_int)) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
139 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
140 fprintf(of, " %04X ", lw_expr_intval(te) & 0xffff); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
141 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
142 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
143 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
144 fprintf(of, " ???? "); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
145 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
146 lw_expr_destroy(te); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
147 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
148 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
149 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
150 fprintf(of, " "); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
151 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
152 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
153 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
154 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
155 lw_expr_t te; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
156 te = lw_expr_copy(cl -> addr); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
157 as -> exportcheck = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
158 as -> csect = cl -> csect; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
159 lwasm_reduce_expr(as, te); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
160 as -> exportcheck = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
161 // fprintf(of, "%s\n", lw_expr_print(te)); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
162 fprintf(of, "%04X ", lw_expr_intval(te) & 0xffff); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
163 lw_expr_destroy(te); |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
164 for (i = 0; i < obytelen && i < 8; i++) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
165 { |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
166 fprintf(of, "%02X", obytes[i]); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
167 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
168 for (; i < 8; i++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
169 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
170 fprintf(of, " "); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
171 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
172 fprintf(of, " "); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
173 } |
14
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
174 /* the 32.32 below is deliberately chosen so that the start of the line text is at |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
175 a multiple of 8 from the start of the list line */ |
14
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
176 fprintf(of, "(%32.32s):%05d ", cl -> linespec, cl -> lineno); |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
177 i = 0; |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
178 for (tc = cl -> ltext; *tc; tc++) |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
179 { |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
180 if ((*tc) == '\t') |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
181 { |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
182 if (i % 8 == 0) |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
183 { |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
184 i += 8; |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
185 fprintf(of, " "); |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
186 } |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
187 else |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
188 { |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
189 while (i % 8) |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
190 { |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
191 fputc(' ', of); |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
192 i++; |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
193 } |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
194 } |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
195 } |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
196 else |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
197 { |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
198 fputc(*tc, of); |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
199 i++; |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
200 } |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
201 } |
5ecdc4dae84d
Brought forward patch to make tabs in listings always display as 8 spaces wide by converting tabs to spaces
lost@l-w.ca
parents:
0
diff
changeset
|
202 fputc('\n', of); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
203 if (cl -> outputl > 8) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
204 { |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
205 for (i = 8; i < obytelen; i++) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
206 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
207 if (i % 8 == 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
208 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
209 if (i != 8) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
210 fprintf(of, "\n "); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
211 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
212 fprintf(of, " "); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
213 } |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
214 fprintf(of, "%02X", obytes[i]); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
215 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
216 if (i > 8) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
217 fprintf(of, "\n"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
218 } |
49
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
219 lw_free(obytes); |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
220 obytes = NULL; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
221 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
222 if (as -> flags & FLAG_SYMBOLS) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
223 list_symbols(as, of); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
224 } |