Mercurial > hg-old > index.cgi
annotate lwasm/list.c @ 388:8991eb507d2d
Added missing arg-nonnull.h ??? file to repo
author | lost@l-w.ca |
---|---|
date | Wed, 14 Jul 2010 20:17:57 -0600 |
parents | a741d2e4869f |
children | fbb7bfed8076 |
rev | line source |
---|---|
384 | 1 /* |
2 list.c | |
3 | |
4 Copyright © 2010 William Astle | |
5 | |
6 This file is part of LWTOOLS. | |
7 | |
8 LWTOOLS is free software: you can redistribute it and/or modify it under the | |
9 terms of the GNU General Public License as published by the Free Software | |
10 Foundation, either version 3 of the License, or (at your option) any later | |
11 version. | |
12 | |
13 This program is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
16 more details. | |
17 | |
18 You should have received a copy of the GNU General Public License along with | |
19 this program. If not, see <http://www.gnu.org/licenses/>. | |
20 */ | |
21 | |
22 #include <config.h> | |
23 | |
24 #include <stdio.h> | |
25 #include <string.h> | |
26 | |
27 #include <lw_alloc.h> | |
28 #include <lw_string.h> | |
29 | |
30 #include "lwasm.h" | |
31 #include "instab.h" | |
32 | |
33 /* | |
34 Do listing | |
35 */ | |
36 void do_list(asmstate_t *as) | |
37 { | |
38 line_t *cl; | |
39 FILE *of; | |
40 int i; | |
41 | |
42 if (!(as -> flags & FLAG_LIST)) | |
43 return; | |
44 | |
45 if (as -> list_file) | |
46 of = fopen(as -> list_file, "w"); | |
47 else | |
48 of = stdout; | |
49 if (!of) | |
50 { | |
51 fprintf(stderr, "Cannot open list file; list not generated\n"); | |
52 return; | |
53 } | |
54 for (cl = as -> line_head; cl; cl = cl -> next) | |
55 { | |
56 if (cl -> len < 1) | |
57 { | |
58 fprintf(of, " "); | |
59 } | |
60 else | |
61 { | |
387
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
62 lw_expr_t te; |
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
63 te = lw_expr_copy(cl -> addr); |
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
64 as -> exportcheck = 1; |
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
65 lwasm_reduce_expr(as, te); |
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
66 as -> exportcheck = 0; |
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
67 fprintf(of, "%04X ", lw_expr_intval(te) & 0xffff); |
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
68 lw_expr_destroy(te); |
384 | 69 for (i = 0; i < cl -> outputl && i < 8; i++) |
70 { | |
71 fprintf(of, "%02X", cl -> output[i]); | |
72 } | |
73 for (; i < 8; i++) | |
74 { | |
75 fprintf(of, " "); | |
76 } | |
77 fprintf(of, " "); | |
78 } | |
79 fprintf(of, "%15s:%05d %s\n", cl -> linespec, cl -> lineno, cl -> ltext); | |
80 if (cl -> outputl > 8) | |
81 { | |
82 for (i = 8; i < cl -> outputl; i++) | |
83 { | |
84 if (i % 8 == 0) | |
85 { | |
86 if (i != 8) | |
87 fprintf(of, "\n "); | |
88 else | |
89 fprintf(of, " "); | |
90 } | |
91 fprintf(of, "%02X", cl -> output[i]); | |
92 } | |
387
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
93 if (i % 8) |
a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
lost@l-w.ca
parents:
384
diff
changeset
|
94 fprintf(of, "\n"); |
384 | 95 } |
96 } | |
97 } |