annotate lwasm/list.c @ 574:a0c9433dc0d4 default tip

Updated submission guidelines including notes about evangelism. TLDR: Don't.
author William Astle <lost@l-w.ca>
date Mon, 04 Mar 2024 10:10:38 -0700
parents 0ae10ecfba1e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
f55650f5e9b8 Fixed problems with macro expansion supression
lost@l-w.ca
parents: 49
diff changeset
38 line_t *cl, *nl, *nl2;
106
43a3f1068027 Adjustments for list code
lost@l-w.ca
parents: 81
diff changeset
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
f55650f5e9b8 Fixed problems with macro expansion supression
lost@l-w.ca
parents: 49
diff changeset
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))
106
43a3f1068027 Adjustments for list code
lost@l-w.ca
parents: 81
diff changeset
47 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
48 of = NULL;
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
49 }
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
50 else
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
51 {
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
52 if (as -> list_file)
106
43a3f1068027 Adjustments for list code
lost@l-w.ca
parents: 81
diff changeset
53 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
54 if (strcmp(as -> list_file, "-") == 0)
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
55 {
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
56 of = stdout;
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
57 }
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
58 else
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
59 of = fopen(as -> list_file, "w");
106
43a3f1068027 Adjustments for list code
lost@l-w.ca
parents: 81
diff changeset
60 }
43a3f1068027 Adjustments for list code
lost@l-w.ca
parents: 81
diff changeset
61 else
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
62 of = stdout;
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
63
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
64 if (!of)
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
65 {
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
66 fprintf(stderr, "Cannot open list file; list not generated\n");
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
67 return;
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
68 }
106
43a3f1068027 Adjustments for list code
lost@l-w.ca
parents: 81
diff changeset
69 }
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
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 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
72 {
319
dc763f806dc4 Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents: 273
diff changeset
73 char *linespec;
dc763f806dc4 Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents: 273
diff changeset
74
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
75 nl = cl -> next;
562
6237505ee1dc Add pragma nolistcode which works like nolist but also suppresses code lines
William Astle <lost@l-w.ca>
parents: 553
diff changeset
76 if (CURPRAGMA(cl, PRAGMA_NOLISTCODE))
6237505ee1dc Add pragma nolistcode which works like nolist but also suppresses code lines
William Astle <lost@l-w.ca>
parents: 553
diff changeset
77 {
6237505ee1dc Add pragma nolistcode which works like nolist but also suppresses code lines
William Astle <lost@l-w.ca>
parents: 553
diff changeset
78 continue;
6237505ee1dc Add pragma nolistcode which works like nolist but also suppresses code lines
William Astle <lost@l-w.ca>
parents: 553
diff changeset
79 }
81
428068681cbf Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents: 50
diff changeset
80 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
81 {
428068681cbf Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents: 50
diff changeset
82 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
83 continue;
428068681cbf Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents: 50
diff changeset
84 }
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 (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
86 {
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 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
88 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
89 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
90 {
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 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
92 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
93 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
94 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
95
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 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
97 obytelen += nl -> outputl;
227
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
98 if (nl -> warn)
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
99 {
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
100 lwasm_error_t *e;
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
101 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
102 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
103 if (of != stdout) printf("Warning (%s:%d): %s\n", cl -> linespec, cl -> lineno, e -> mess);
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
104 if (of) fprintf(of, "Warning: %s\n", e -> mess);
227
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
105 }
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
106 }
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 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
108 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
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 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
111 nc = 0;
50
f55650f5e9b8 Fixed problems with macro expansion supression
lost@l-w.ca
parents: 49
diff changeset
112 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
113 {
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 42
diff changeset
114 int i;
50
f55650f5e9b8 Fixed problems with macro expansion supression
lost@l-w.ca
parents: 49
diff changeset
115 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
116 {
50
f55650f5e9b8 Fixed problems with macro expansion supression
lost@l-w.ca
parents: 49
diff changeset
117 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
118 }
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 42
diff changeset
119 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
120 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
121 }
273
1409debcb1a0 Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents: 230
diff changeset
122 if (nl)
1409debcb1a0 Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents: 230
diff changeset
123 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
124 }
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 42
diff changeset
125 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
126 {
227
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
127 if (cl -> warn)
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
128 {
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
129 lwasm_error_t *e;
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
130 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
131 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
132 if (of != stdout) printf("Warning (%s:%d): %s\n", cl -> linespec, cl -> lineno, e -> mess);
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
133 if (of) fprintf(of, "Warning: %s\n", e -> mess);
227
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
134 }
721a5ea5e36a Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents: 194
diff changeset
135 }
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
136 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
137 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
138 {
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 42
diff changeset
139 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
140 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
141 }
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 42
diff changeset
142 }
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 457
diff changeset
143 if (cl -> hidecond && CURPRAGMA(cl, PRAGMA_NOEXPANDCOND))
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 457
diff changeset
144 continue;
357
b6933dc299e6 Make listings show the address for lines that only define symbols
William Astle <lost@l-w.ca>
parents: 319
diff changeset
145 if ((cl -> len < 1 && cl -> dlen < 1) && obytelen < 1 && (cl -> symset == 1 || cl -> sym == 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
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 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
148 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
149 if (of) 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
150 }
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 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
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 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
154 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
155 if (of) 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
156 }
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 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
158 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
159 if (of) fprintf(of, " %04X ", 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
160 }
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 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
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 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
165 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
166 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
167 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
168 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
169 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
170 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
171 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
172 if (of) fprintf(of, " %04X ", lw_expr_intval(te) & 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
173 }
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 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
175 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
176 if (of) fprintf(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
177 }
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
178 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
179 }
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 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
181 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
182 if (of) fprintf(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
183 }
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 }
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
185 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
186 {
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
187 lw_expr_t te;
542
f3018ed5e30e Fix listing to not rely on undefined memory before the start of instab
William Astle <lost@l-w.ca>
parents: 508
diff changeset
188 if ((cl -> insn >= 0) && (instab[cl -> insn].flags & lwasm_insn_setdata))
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 106
diff changeset
189 te = lw_expr_copy(cl -> daddr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 106
diff changeset
190 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 106
diff changeset
191 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
192 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
193 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
194 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
195 as -> exportcheck = 0;
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
196 // if (of) fprintf(of, "%s\n", lw_expr_print(te));
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
197 if (of) 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
198 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
199 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
200 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
201 if (of) 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
202 }
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 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
204 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
205 if (of) fprintf(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
206 }
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
207 if (of) fprintf(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
208 }
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
209
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
210 /* the format specifier below is deliberately chosen so that the start of the line text is at
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
211 a multiple of 8 from the start of the list line */
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
212
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
213 #define max_linespec_len 17
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
214
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
215 // trim "include:" if it appears
442
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
216 if (as -> listnofile)
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
217 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
218 if (of) fprintf(of, "%05d ", cl->lineno);
442
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
219 }
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
220 else
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
221 {
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
222 linespec = cl -> linespec;
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
223 if ((strlen(linespec) > 8) && (linespec[7] == ':')) linespec += 8;
573
0ae10ecfba1e Make filename in listing left truncate so file name isn't hidden
William Astle <lost@l-w.ca>
parents: 562
diff changeset
224 if (strlen(linespec) > max_linespec_len)
0ae10ecfba1e Make filename in listing left truncate so file name isn't hidden
William Astle <lost@l-w.ca>
parents: 562
diff changeset
225 linespec += strlen(linespec) - max_linespec_len;
442
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
226 while (*linespec == ' ') linespec++;
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
227
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
228 if (of) fprintf(of, "(%*.*s):%05d ", max_linespec_len, max_linespec_len, linespec, cl->lineno);
442
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
229 }
61580fc48f98 Add option to omit file names from lwasm listings
William Astle <lost@l-w.ca>
parents: 390
diff changeset
230
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
231 if (CURPRAGMA(cl, PRAGMA_CC))
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
232 {
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
233 as->cycle_total = 0;
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
234 }
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
235
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
236 /* display cycle counts */
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
237 char s[64] = "";
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
238 if (CURPRAGMA(cl, PRAGMA_C) || CURPRAGMA(cl, PRAGMA_CD))
319
dc763f806dc4 Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents: 273
diff changeset
239 {
508
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
240 char sch = '(', ech = ')';
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
241 if (CURPRAGMA(cl, PRAGMA_6809))
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
242 {
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
243 sch = '[';
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
244 ech = ']';
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
245 }
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
246 if (cl->cycle_base != 0)
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
247 {
508
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
248 int est = cl -> cycle_flags & CYCLE_ESTIMATED;
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
249
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
250 if (CURPRAGMA(cl, PRAGMA_CD) && cl->cycle_flags & CYCLE_ADJ)
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
251 {
508
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
252 sprintf(s, "%c%d+%d%s%c", sch, cl->cycle_base, cl->cycle_adj, est ? "+?" : "", ech); /* detailed cycle count */
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
253 }
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
254 else
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
255 {
508
10f62dc61a75 Fix bad usage of sprintf()
William Astle <lost@l-w.ca>
parents: 483
diff changeset
256 sprintf(s, "%c%d%s%c", sch, cl->cycle_base + cl->cycle_adj, est ? "+?" : "", ech); /* normal cycle count*/
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
257 }
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
258 as->cycle_total += cl->cycle_base + cl->cycle_adj;
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
259 }
319
dc763f806dc4 Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents: 273
diff changeset
260 }
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
261
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
262 if (of) fprintf(of, "%-8s", s);
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
263
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
264 if (CURPRAGMA(cl, PRAGMA_CT))
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
265 {
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
266 if (cl->cycle_base != 0)
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
267 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
268 if (of) fprintf(of, "%-8d", as->cycle_total);
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
269 }
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
270 else
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
271 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
272 if (of) fprintf(of, " ");
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
273 }
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
274 }
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 357
diff changeset
275
390
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
276 if (as -> tabwidth == 0)
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
277 {
553
3a173cefc814 Fix missing NULL guard found by gcc static analysis
William Astle <lost@l-w.ca>
parents: 542
diff changeset
278 if (of) fputs(cl -> ltext, of);
390
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
279 }
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
280 else
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
281 {
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
282 i = 0;
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
283 for (tc = cl -> ltext; *tc; tc++)
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
284 {
390
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
285 if ((*tc) == '\t')
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
286 {
390
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
287 if (i % as -> tabwidth == 0)
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
288 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
289 if (of) fputc(' ', of);
390
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
290 i++;
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
291 }
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
292 while (i % as -> tabwidth)
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
293 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
294 if (of) fputc(' ', of);
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
295 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
296 }
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
297 }
390
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
298 else
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
299 {
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
300 if (of) fputc(*tc, of);
390
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
301 i++;
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
302 }
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
303 }
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
304 }
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
305 if (of) fputc('\n', of);
390
1ebb5a0b2874 Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents: 376
diff changeset
306
194
f8b33b3a45ac Fix noexpand macro listings to show all bytes output
William Astle <lost@l-w.ca>
parents: 142
diff changeset
307 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
308 {
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
309 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
310 {
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
311 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
312 {
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
313 if (i != 8)
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
314 {
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
315 if (of) fprintf(of, "\n ");
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
316 }
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
317 else
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
318 {
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
319 if (of) fprintf(of, " ");
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
320 }
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
321 }
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
322 if (of) 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
323 }
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
324 if (i > 8)
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
325 if (of) fprintf(of, "\n");
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
326 }
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
327 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
328 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
329 }
483
40c32a0af8c8 Fix crash when --symbols specified without --list
William Astle <lost@l-w.ca>
parents: 474
diff changeset
330 if ((as -> flags & FLAG_SYMBOLS) && 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
331 list_symbols(as, of);
457
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
332 if (of && of != stdout)
7d6eacd87370 Make warnings still show when listings are not enabled.
William Astle <lost@l-w.ca>
parents: 456
diff changeset
333 fclose(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
334 }