Mercurial > hg > forks > dxa
annotate vector.c @ 13:cfa260872b23
Bump version.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 08 Oct 2021 02:40:00 +0300 |
parents | ec2f8f6f1dc9 |
children | a2a81589380d |
rev | line source |
---|---|
0 | 1 /*\ |
2 * dxa v0.1.1 -- symbolic 65xx disassembler | |
3 * | |
4 * Copyright (C) 1993, 1994 Marko M\"akel\"a | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 * | |
20 * Contacting the author: | |
21 * | |
22 * Via Internet E-mail: | |
23 * <Marko.Makela@FTP.FUNET.FI> | |
24 * | |
25 * Via Snail Mail: | |
26 * Marko M\"akel\"a | |
27 * Sillitie 10 A | |
28 * FIN-01480 VANTAA | |
29 * Finland | |
30 \*/ | |
31 | |
32 #define _VECTOR_C_ | |
33 | |
34 #include <stdio.h> | |
35 #include <stdlib.h> | |
36 | |
37 #include "proto.h" | |
38 #include "options.h" | |
39 | |
40 unsigned WordCount = 0; | |
41 words *WordTable = NULL; | |
42 | |
43 | |
44 void AddWordEntry (ADDR_T start, ADDR_T end) | |
45 { | |
46 words *entry; | |
47 | |
48 entry = WordCount ? | |
49 realloc (WordTable, (WordCount + 1) * sizeof *entry) : | |
50 malloc (sizeof *entry); | |
51 | |
52 if (!entry) return; | |
53 | |
54 WordTable = entry; | |
55 entry += WordCount++; | |
56 entry->start = start; | |
57 entry->end = end; | |
58 } | |
59 | |
2
ec2f8f6f1dc9
Cleanup pass #1: Get rid of some ancient K&R-isms.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
60 |
0 | 61 ADDR_T WordTableEnd (ADDR_T start) |
62 { | |
63 words *entry; | |
64 | |
65 if (!((entry = &WordTable[WordCount]))) | |
66 return start; | |
67 | |
68 while (entry-- > WordTable) | |
69 if (entry->start == start) | |
70 return entry->end; | |
71 | |
72 return start; | |
73 } | |
74 | |
2
ec2f8f6f1dc9
Cleanup pass #1: Get rid of some ancient K&R-isms.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
75 |
0 | 76 void SearchVectors (void) |
77 { | |
78 ADDR_T start, end, address; | |
79 | |
80 if ((Options & M_ADR_TABLES) == O_TBL_IGNORE) return; | |
81 | |
82 if (fVerbose) | |
83 fprintf (stderr, "%s: Searching for address tables.\n", prog); | |
84 | |
85 for (start = StartAddress; start != EndAddress; start++) { | |
86 if (GetMemType (start) != MEM_DATA || !IsLowByte (Memory[start])) | |
87 continue; | |
88 | |
89 for (end = start; (end | 1) != (1 | EndAddress); end += 2) { | |
90 if (GetMemType (end) != MEM_DATA || GetMemType (end + 1) != MEM_DATA) | |
91 break; | |
92 | |
93 address = Memory[end] | (Memory[(ADDR_T)(end + 1)] << 8); | |
94 | |
95 if (!IsLabeled (address)) | |
96 break; | |
97 | |
98 if ((Options & M_ADR_TABLES) == O_TBL_NOEXT && | |
99 (ADDR_T)(address - StartAddress) >= | |
100 (ADDR_T)(EndAddress - StartAddress)) | |
101 break; | |
102 } | |
103 | |
104 if ((ADDR_T)(end - start) > 2) { | |
105 AddWordEntry (start, end); | |
106 if (EndAddress == (start = end)) break; | |
107 } | |
108 } | |
109 } |