Mercurial > hg > index.cgi
annotate lwasm/list.c @ 417:d7b7004b0883
Update gcc6809 patch to fix an ICE.
Add new gcc6809 patch with a fix to an internal compiler error reported by
Tormod Volden. It seems whoever created the offending instruction patterns
didn't fully understand the instruction contraints system and likely got
away with it due to characteristics of the instruction generator in previous
versions of gcc. Alas, it causes problems now so unless someone has a
brilliant idea how to make it work, addhi_mem_1 and addhi_mem_minus1 have to
go. Fortunately, the compiler is smart enough to use an alternate strategy
all on its own.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 27 Mar 2016 21:46:18 -0600 |
parents | 1ebb5a0b2874 |
children | 61580fc48f98 |
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 |
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
|
70 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
|
71 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
|
72 { |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
73 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
|
74 continue; |
428068681cbf
Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents:
50
diff
changeset
|
75 } |
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
|
76 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
|
77 { |
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 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
|
79 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
|
80 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
|
81 { |
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_start) |
273
1409debcb1a0
Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents:
230
diff
changeset
|
83 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
|
84 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
|
85 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
|
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 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
|
88 obytelen += nl -> outputl; |
227
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
89 if (nl -> warn) |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
90 { |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
91 lwasm_error_t *e; |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
92 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
|
93 { |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
94 printf("Warning: %s\n", e -> mess); |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
95 } |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
96 } |
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
|
97 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
|
98 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
|
99 } |
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 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
|
101 nc = 0; |
50 | 102 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
|
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 int i; |
50 | 105 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
|
106 { |
50 | 107 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
|
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 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
|
110 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
|
111 } |
273
1409debcb1a0
Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents:
230
diff
changeset
|
112 if (nl) |
1409debcb1a0
Fix crash on listing when nested noexpand macros are used
William Astle <lost@l-w.ca>
parents:
230
diff
changeset
|
113 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
|
114 } |
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 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
|
116 { |
227
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
117 if (cl -> warn) |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
118 { |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
119 lwasm_error_t *e; |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
120 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
|
121 { |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
122 printf("Warning: %s\n", e -> mess); |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
123 } |
721a5ea5e36a
Make warnings show up in assembly listings.
William Astle <lost@l-w.ca>
parents:
194
diff
changeset
|
124 } |
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
|
125 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
|
126 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
|
127 { |
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 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
|
129 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
|
130 } |
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 } |
357
b6933dc299e6
Make listings show the address for lines that only define symbols
William Astle <lost@l-w.ca>
parents:
319
diff
changeset
|
132 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
|
133 { |
2c24602be78f
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 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
|
135 { |
142
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
136 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
|
137 } |
2c24602be78f
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 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
|
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 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
|
141 { |
42 | 142 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
|
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 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
|
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 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
|
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 } |
2c24602be78f
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 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
|
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 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 { |
2c24602be78f
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 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
|
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 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
|
162 { |
2c24602be78f
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 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
|
164 } |
2c24602be78f
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 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
|
166 } |
2c24602be78f
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 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
|
168 { |
2c24602be78f
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 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
|
170 } |
2c24602be78f
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 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
|
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 lw_expr_t te; |
142
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
175 if (instab[cl -> insn].flags & lwasm_insn_setdata) |
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
176 te = lw_expr_copy(cl -> daddr); |
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
177 else |
697bc543368c
Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents:
106
diff
changeset
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 // 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
|
184 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
|
185 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
|
186 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
|
187 { |
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
|
188 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
|
189 } |
2c24602be78f
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 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
|
191 { |
2c24602be78f
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 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
|
193 } |
2c24602be78f
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 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
|
195 } |
376 | 196 |
197 /* the format specifier below is deliberately chosen so that the start of the line text is at | |
198 a multiple of 8 from the start of the list line */ | |
199 | |
200 #define max_linespec_len 17 | |
201 | |
202 // trim "include:" if it appears | |
203 linespec = cl -> linespec; | |
204 if ((strlen(linespec) > 8) && (linespec[7] == ':')) linespec += 8; | |
205 while (*linespec == ' ') linespec++; | |
206 | |
207 fprintf(of, "(%*.*s):%05d ", max_linespec_len, max_linespec_len, linespec, cl->lineno); | |
208 | |
209 if (CURPRAGMA(cl, PRAGMA_CC)) | |
210 { | |
211 as->cycle_total = 0; | |
212 } | |
213 | |
214 /* display cycle counts */ | |
215 char s[64] = ""; | |
216 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
|
217 { |
376 | 218 if (cl->cycle_base != 0) |
219 { | |
220 char ch = '('; | |
221 if (CURPRAGMA(cl, PRAGMA_6809)) ch = '['; | |
222 | |
223 if (CURPRAGMA(cl, PRAGMA_CD) && cl->cycle_flags & CYCLE_ADJ) | |
224 { | |
225 sprintf(s, "%c%d+%d", ch, cl->cycle_base, cl->cycle_adj); /* detailed cycle count */ | |
226 } | |
227 else | |
228 { | |
229 sprintf(s, "%c%d", ch, cl->cycle_base + cl->cycle_adj); /* normal cycle count*/ | |
230 } | |
231 | |
232 if (cl->cycle_flags & CYCLE_ESTIMATED) | |
233 strcat(s, "+?"); | |
234 | |
235 as->cycle_total += cl->cycle_base + cl->cycle_adj; | |
236 | |
237 ch = ')'; | |
238 if (CURPRAGMA(cl, PRAGMA_6809)) ch = ']'; | |
239 sprintf(s, "%s%c", s, ch); | |
240 } | |
319
dc763f806dc4
Left truncate file names in list output.
William Astle <lost@l-w.ca>
parents:
273
diff
changeset
|
241 } |
376 | 242 |
243 fprintf(of, "%-8s", s); | |
244 | |
245 if (CURPRAGMA(cl, PRAGMA_CT)) | |
246 { | |
247 if (cl->cycle_base != 0) | |
248 { | |
249 fprintf(of, "%-8d", as->cycle_total); | |
250 } | |
251 else | |
252 { | |
253 fprintf(of, " "); | |
254 } | |
255 } | |
256 | |
390
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
257 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
|
258 { |
390
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
259 fputs(cl -> ltext, of); |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
260 } |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
261 else |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
262 { |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
263 i = 0; |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
264 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
|
265 { |
390
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
266 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
|
267 { |
390
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
268 if (i % as -> tabwidth == 0) |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
269 { |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
270 fputc(' ', of); |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
271 i++; |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
272 } |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
273 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
|
274 { |
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
|
275 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
|
276 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
|
277 } |
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
|
278 } |
390
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
279 else |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
280 { |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
281 fputc(*tc, of); |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
282 i++; |
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
283 } |
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 } |
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
|
285 } |
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 fputc('\n', of); |
390
1ebb5a0b2874
Add option to specify tab width in listing
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
287 |
194
f8b33b3a45ac
Fix noexpand macro listings to show all bytes output
William Astle <lost@l-w.ca>
parents:
142
diff
changeset
|
288 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
|
289 { |
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
|
290 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
|
291 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
292 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
|
293 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
294 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
|
295 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
|
296 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
|
297 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
|
298 } |
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
|
299 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
|
300 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
301 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
|
302 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
|
303 } |
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
|
304 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
|
305 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
|
306 } |
230
e09985968e64
Don't suppress symbol listing in unicorns mode
William Astle <lost@l-w.ca>
parents:
227
diff
changeset
|
307 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
|
308 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
|
309 } |