Mercurial > hg > index.cgi
annotate lwasm/list.c @ 319:dc763f806dc4
Left truncate file names in list output.
Thanks to Tormod Volden (lists.tormod@gmail.com) for providing this patch to
truncate long file names on the left instead of the right when producing the
listing output.
author | William Astle <lost@l-w.ca> |
---|---|
date | Tue, 04 Feb 2014 20:16:35 -0700 |
parents | 1409debcb1a0 |
children | b6933dc299e6 |
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 { |
319
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
68 char *linespec; |
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
69 int linespec_len; |
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
70 |
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
|
71 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
|
72 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
|
73 { |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
74 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
|
75 continue; |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
76 } |
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
|
77 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
|
78 { |
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 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
|
80 int nc = 0; |
273
1409debcb1a0
Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents:
230
diff
changeset
|
81 for (nl = cl; nl; nl = nl -> 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
|
82 { |
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 if (nl -> noexpand_start) |
273
1409debcb1a0
Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents:
230
diff
changeset
|
84 nc += nl -> noexpand_start; |
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
|
85 if (nl -> noexpand_end) |
273
1409debcb1a0
Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents:
230
diff
changeset
|
86 nc -= nl -> noexpand_end; |
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
|
87 |
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 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
|
89 obytelen += nl -> outputl; |
227
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
90 if (nl -> warn) |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
91 { |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
92 lwasm_error_t *e; |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
93 for (e = nl -> warn; e; e = e -> next) |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
94 { |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
95 printf("Warning: %s\n", e -> mess); |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
96 } |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
97 } |
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 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
|
99 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
|
100 } |
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 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
|
102 nc = 0; |
50 | 103 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
|
104 { |
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 int i; |
50 | 106 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
|
107 { |
50 | 108 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
|
109 } |
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 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
|
111 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
|
112 } |
273
1409debcb1a0
Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents:
230
diff
changeset
|
113 if (nl) |
1409debcb1a0
Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents:
230
diff
changeset
|
114 nl = nl -> 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
|
115 } |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
116 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
|
117 { |
227
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
118 if (cl -> warn) |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
119 { |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
120 lwasm_error_t *e; |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
121 for (e = cl -> warn; e; e = e -> next) |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
122 { |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
123 printf("Warning: %s\n", e -> mess); |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
124 } |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
125 } |
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
|
126 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
|
127 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
|
128 { |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
129 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
|
130 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
|
131 } |
bd8b3fbd1e28
Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents:
42
diff
changeset
|
132 } |
142
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
133 if ((cl -> len < 1 && cl -> dlen < 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
|
134 { |
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 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
|
136 { |
142
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
137 fprintf(of, "%04Xs ", cl -> soff & 0xffff); |
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 } |
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 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
|
140 { |
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 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
|
142 { |
42 | 143 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
|
144 } |
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 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
|
146 { |
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 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
|
148 } |
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 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
|
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 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 { |
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 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
|
161 } |
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 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
|
163 { |
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
|
164 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
|
165 } |
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
|
166 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
|
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 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
|
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 } |
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 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
|
174 { |
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 lw_expr_t te; |
142
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
176 if (instab[cl -> insn].flags & lwasm_insn_setdata) |
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
177 te = lw_expr_copy(cl -> daddr); |
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
178 else |
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
179 te = lw_expr_copy(cl -> addr); |
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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 // fprintf(of, "%s\n", lw_expr_print(te)); |
142
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
185 fprintf(of, "%04X%c", lw_expr_intval(te) & 0xffff, ((cl -> inmod || (cl -> dlen != cl -> len)) && instab[cl -> insn].flags & lwasm_insn_setdata) ? '.' : ' '); |
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
|
186 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
|
187 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
|
188 { |
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
|
189 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
|
190 } |
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
|
191 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
|
192 { |
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
|
193 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
|
194 } |
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
|
195 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
|
196 } |
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
|
197 /* 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
|
198 a multiple of 8 from the start of the list line */ |
319
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
199 linespec = cl -> linespec; |
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
200 linespec_len = strlen(linespec); |
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
201 if (linespec_len > 32) |
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
202 { |
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
203 linespec += linespec_len - 32; |
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
204 } |
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
205 fprintf(of, "(%32.32s):%05d ", linespec, cl -> lineno); |
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
|
206 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
|
207 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
|
208 { |
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
|
209 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
|
210 { |
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
|
211 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
|
212 { |
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
|
213 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
|
214 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
|
215 } |
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
|
216 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
|
217 { |
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
|
218 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
|
219 { |
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
|
220 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
|
221 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
|
222 } |
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
|
223 } |
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
|
224 } |
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
|
225 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
|
226 { |
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
|
227 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
|
228 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
|
229 } |
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
|
230 } |
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
|
231 fputc('\n', of); |
194
f8b33b3a45ac
Fix noexpand macro listings to show all bytes output
William Astle <lost@l-w.ca>
parents:
142
diff
changeset
|
232 if (obytelen > 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
|
233 { |
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
|
234 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
|
235 { |
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
|
236 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
|
237 { |
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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 } |
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
|
243 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
|
244 } |
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
|
245 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
|
246 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
|
247 } |
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
|
248 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
|
249 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
|
250 } |
230
e09985968e64
Don't suppress symbol listing in unicorns mode
William Astle <lost@l-w.ca>
parents:
227
diff
changeset
|
251 if ((as -> flags & FLAG_SYMBOLS)) |
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
|
252 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
|
253 } |