Mercurial > hg > forks > dxa
annotate dump.c @ 16:a2a81589380d default tip
Reformat the whole source via clang-format for better consistency.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 14 Oct 2021 01:53:20 +0300 |
parents | 89183953bddc |
children |
rev | line source |
---|---|
0 | 1 /*\ |
14
84c0facfc43c
Merge changes from upstream v0.1.4.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
2 * dxa -- symbolic 65xx disassembler |
0 | 3 * |
4 * Copyright (C) 1993, 1994 Marko M\"akel\"a | |
14
84c0facfc43c
Merge changes from upstream v0.1.4.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
5 * Changes for dxa (C) 2004-2019 Cameron Kaiser |
0 | 6 * |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 * | |
21 * Marko does not maintain dxa, so questions specific to dxa should be | |
14
84c0facfc43c
Merge changes from upstream v0.1.4.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
22 * sent to me at ckaiser@floodgap.com. |
0 | 23 * |
24 \*/ | |
25 | |
26 #define _DUMP_C_ | |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
29 | |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
30 #include "opcodes.h" |
0 | 31 #include "options.h" |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
32 #include "proto.h" |
0 | 33 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
34 void Dump(void) |
0 | 35 { |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
36 ADDR_T address, addr; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
37 unsigned counter, size, maxwidth; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
38 char *lineprefix, *lineinfix; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
39 table *entry; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
40 opcodes *instr; |
0 | 41 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
42 if (fVerbose) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
43 fprintf(stderr, "%s: Dumping the source code.\n", prog); |
0 | 44 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
45 /* determine the maximum amount of bytes dumped per line */ |
0 | 46 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
47 maxwidth = listwidth < 2 ? 2 : listwidth; |
0 | 48 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
49 for (counter = 0; counter < 256; counter++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
50 if (maxwidth < sizes[opset[counter].admode]) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
51 maxwidth = sizes[opset[counter].admode]; |
0 | 52 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
53 /* create prefix string for lines without address information */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
54 switch (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
55 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
56 case O_ADR_ADRPFIX: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
57 counter = 5; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
58 break; |
0 | 59 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
60 case O_ADR_ADR_DMP: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
61 counter = 5 + 3 * maxwidth; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
62 break; |
0 | 63 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
64 default: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
65 counter = 0; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
66 } |
0 | 67 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
68 lineprefix = malloc(counter + 1); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
69 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
70 if (counter >= 5) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
71 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
72 lineinfix = lineprefix + 5; |
0 | 73 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
74 for (lineprefix[counter] = 0; counter--; lineprefix[counter] = ' '); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
75 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
76 else |
10 | 77 { |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
78 *lineprefix = 0; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
79 lineinfix = lineprefix; |
10 | 80 } |
0 | 81 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
82 /* print the label definitions */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
83 for (address = EndAddress < StartAddress ? EndAddress : 0; address != StartAddress; address++) |
10 | 84 { |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
85 if (IsLabeled(address) && !IsInsideRegion(address) && IsReferenced(address)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
86 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
87 fprintf(stdout, "%s%s = $%x\n", lineprefix, Label(address, abso, 0), address); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
88 } |
10 | 89 } |
0 | 90 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
91 if (EndAddress >= StartAddress) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
92 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
93 for (address = EndAddress; address; address++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
94 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
95 if (IsLabeled(address) && !IsInsideRegion(address) && IsReferenced(address)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
96 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
97 fprintf(stdout, "%s%s = $%x\n", lineprefix, Label(address, abso, 0), address); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
98 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
99 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
100 } |
11
fe4d840c13eb
Implement reference checking to reduce outputting of useless labels.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
101 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
102 /* dump the program */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
103 fprintf(stdout, "\n\n"); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
104 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
105 if (Options & B_SA_WORD) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
106 fprintf(stdout, "%s\t.word $%04x", lineprefix, StartAddress); |
0 | 107 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
108 fprintf(stdout, "\n%s\t* = $%04x\n\n", lineprefix, StartAddress); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
109 if (BasicHeaderLength) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
110 fprintf(stdout, "; %d byte BASIC header.\n", BasicHeaderLength); |
0 | 111 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
112 for (address = StartAddress; (ADDR_T)(address - StartAddress) < (ADDR_T)(EndAddress - StartAddress); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
113 address += size) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
114 if (GetMemType(address) == MEM_INSTRUCTION) |
11
fe4d840c13eb
Implement reference checking to reduce outputting of useless labels.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
115 { |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
116 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
117 if (IsLabeled(address) && IsReferenced(address)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
118 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
119 if (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
120 fprintf(stdout, "%04x %s%s:\n", address, lineinfix, Label(address, abso, 0)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
121 else |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
122 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
123 fprintf(stdout, "%s", Label(address, abso, 0)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
124 if (Options & B_LABCOL) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
125 fprintf(stdout, ":\n"); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
126 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
127 } |
0 | 128 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
129 instr = &opset[Memory[address]]; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
130 size = sizes[instr->admode]; |
0 | 131 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
132 for (counter = 1; counter < size; counter++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
133 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
134 if (IsLabeled(address + counter)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
135 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
136 if (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
137 fprintf(stdout, "\t%04x %s%s = * + %u\n", (ADDR_T)(address + counter), lineinfix, |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
138 Label(address + counter, abso, 0), counter); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
139 else |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
140 fprintf(stdout, "\t%s = * + %u\n", Label(address + counter, abso, 0), counter); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
141 } |
0 | 142 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
143 if (FindNextEntry(NULL, address, ~0, WRN_INSTR_WRITTEN_TO)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
144 fprintf(stdout, "%s; Instruction opcode $%04x accessed.\n", lineprefix, address); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
145 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
146 entry = NULL; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
147 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
148 while ((entry = FindNextEntry(entry, address + counter, 0, 0))) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
149 switch (entry->type) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
150 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
151 case WRN_PARAM_WRITTEN_TO: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
152 fprintf(stdout, "%s; Instruction parameter $%04x accessed.\n", lineprefix, address + counter); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
153 break; |
0 | 154 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
155 case WRN_PARAM_JUMPED_TO: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
156 fprintf(stdout, "%s; Instruction parameter $%04x jumped to.\n", lineprefix, address + counter); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
157 break; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
158 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
159 } |
0 | 160 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
161 switch (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
162 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
163 case O_ADR_ADRPFIX: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
164 fprintf(stdout, "%04x ", address); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
165 break; |
0 | 166 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
167 case O_ADR_ADR_DMP: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
168 fprintf(stdout, "%04x ", address); |
0 | 169 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
170 for (counter = 0; counter < size; counter++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
171 fprintf(stdout, "%02x ", Memory[(ADDR_T)(address + counter)]); |
0 | 172 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
173 fputs(lineinfix + 3 * counter, stdout); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
174 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
175 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
176 fputs("\t", stdout); |
0 | 177 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
178 switch (instr->admode) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
179 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
180 case accu: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
181 case impl: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
182 fprintf(stdout, "%s%s\n", mne[instr->mnemonic], postfix[instr->admode]); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
183 break; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
184 case imm: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
185 addr = Memory[(ADDR_T)(address + 1)]; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
186 fprintf(stdout, "%s #$%02x\n", mne[instr->mnemonic], addr); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
187 break; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
188 case abso: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
189 case absx: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
190 case absy: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
191 case iabs: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
192 case iabsx: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
193 addr = Memory[(ADDR_T)(address + 1)] | (Memory[(ADDR_T)(address + 2)] << 8); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
194 /* Fix to ensure 16-bit addresses to zero-page are maintained as 16-bit */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
195 fprintf(stdout, "%s %s%s%s%s\n", mne[instr->mnemonic], prefix[instr->admode], |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
196 ((addr < 256 && instr->mnemonic != S_JMP && instr->mnemonic != S_JSR) ? "!" : ""), |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
197 Label(addr, abso, 1), postfix[instr->admode]); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
198 break; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
199 case zp: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
200 case zpx: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
201 case zpy: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
202 case ind: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
203 case indx: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
204 case indy: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
205 addr = Memory[(ADDR_T)(address + 1)]; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
206 fprintf(stdout, "%s %s%s%s\n", mne[instr->mnemonic], prefix[instr->admode], Label(addr, zp, 1), |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
207 postfix[instr->admode]); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
208 break; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
209 case rel: |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
210 addr = (int)(char)Memory[(ADDR_T)(address + 1)]; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
211 /* addr -= (addr > 127) ? 256 : 0; BUGFIX: sign extend already done */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
212 /*fprintf(stderr, "%d %d %d\n", address, size, addr);*/ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
213 addr += address + size; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
214 fprintf(stdout, "%s %s%s%s\n", mne[instr->mnemonic], prefix[instr->admode], Label(addr, abso, 1), |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
215 postfix[instr->admode]); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
216 break; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
217 case zrel: /* BBR0, etc. 65C02 instructions */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
218 addr = (int)(char)Memory[(ADDR_T)(address + 2)]; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
219 /* addr -= (addr > 127) ? 256 : 0; BUGFIX: sign extend already done */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
220 addr += address + size; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
221 fprintf(stdout, "%s %s, %s\n", mne[instr->mnemonic], Label(Memory[(ADDR_T)(address + 1)], abso, 1), |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
222 Label(addr, abso, 1)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
223 break; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
224 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
225 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
226 else if (address != (addr = WordTableEnd(address))) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
227 { /* word table */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
228 for (size = (ADDR_T)(addr - address); size; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
229 address += (counter = size > (maxwidth & ~1) ? (maxwidth & ~1) : size), size -= counter) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
230 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
231 if (IsLabeled(address)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
232 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
233 if (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
234 fprintf(stdout, "%04x %s%s:\n", address, lineinfix, Label(address, abso, 0)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
235 else |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
236 fprintf(stdout, "%s ", Label(address, abso, 0)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
237 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
238 for (counter = size > (maxwidth & ~1) ? (maxwidth & ~1) : size, addr = address + 1; --counter; addr++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
239 if (IsLabeled(addr)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
240 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
241 if (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
242 fprintf(stdout, "%04x %s%s = * + %u\n", addr, lineinfix, Label(addr, abso, 0), |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
243 (ADDR_T)(addr - address)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
244 else |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
245 fprintf(stdout, "\t%s = * + %u\n", Label(addr, abso, 0), (ADDR_T)(addr - address)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
246 } |
0 | 247 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
248 if (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
249 fprintf(stdout, "%04x ", address); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
250 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
251 if ((Options & M_ADDRESSES) == O_ADR_ADR_DMP) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
252 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
253 for (counter = size > (maxwidth & ~1) ? (maxwidth & ~1) : size, addr = address; counter--; addr++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
254 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
255 fprintf(stdout, "%02x ", Memory[addr]); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
256 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
257 fputs(lineinfix + 3 * (size > (maxwidth & ~1) ? (maxwidth & ~1) : size), stdout); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
258 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
259 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
260 fprintf(stdout, " .word %s", Label(Memory[address] | (Memory[(ADDR_T)(address + 1)] << 8), abso, 0)); |
0 | 261 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
262 for (counter = size > (maxwidth & ~1) ? (maxwidth & ~1) : size, addr = address + 2; counter -= 2; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
263 addr += 2) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
264 fprintf(stdout, ",%s", Label(Memory[addr] | (Memory[(ADDR_T)(addr + 1)] << 8), abso, 0)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
265 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
266 fputc('\n', stdout); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
267 } |
0 | 268 } |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
269 else |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
270 { /* data block */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
271 for (size = 1; size < maxwidth; size++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
272 { /* determine the size */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
273 addr = address + size; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
274 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
275 if (GetMemType(addr) == MEM_INSTRUCTION || addr != WordTableEnd(addr)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
276 break; |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
277 } |
0 | 278 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
279 if (IsLabeled(address)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
280 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
281 if (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
282 fprintf(stdout, "%04x %s%s:\n", address, lineinfix, Label(address, abso, 0)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
283 else |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
284 fprintf(stdout, "%s ", Label(address, abso, 0)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
285 } |
0 | 286 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
287 for (counter = size, addr = address + 1; --counter; addr++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
288 if (IsLabeled(addr)) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
289 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
290 if (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
291 fprintf(stdout, "%04x %s%s = * + %u\n", addr, lineinfix, Label(addr, abso, 0), |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
292 (ADDR_T)(addr - address)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
293 else |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
294 fprintf(stdout, "\t%s = * + %u\n", Label(addr, abso, 0), (ADDR_T)(addr - address)); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
295 } |
0 | 296 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
297 if (Options & M_ADDRESSES) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
298 fprintf(stdout, "%04x ", address); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
299 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
300 if ((Options & M_ADDRESSES) == O_ADR_ADR_DMP) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
301 { |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
302 for (counter = size, addr = address; counter--; addr++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
303 fprintf(stdout, "%02x ", Memory[addr]); |
0 | 304 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
305 fputs(lineinfix + 3 * size, stdout); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
306 } |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
307 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
308 fprintf(stdout, "\t.byt $%02x", Memory[address]); |
0 | 309 |
16
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
310 for (counter = size, addr = address + 1; --counter; addr++) |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
311 if (addr < EndAddress) /* problems with this overflowing */ |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
312 fprintf(stdout, ",$%02x", Memory[addr]); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
313 |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
314 fputc('\n', stdout); |
a2a81589380d
Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
315 } |
0 | 316 } |