annotate scan.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 84c0facfc43c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 *
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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 * Copyright (C) 2019 Cameron Kaiser
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 *
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 * (at your option) any later version.
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 *
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 * GNU General Public License for more details.
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 *
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 *
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 \*/
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 #define _SCAN_C_
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 #include "opcodes.h"
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 #include "options.h"
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
26 #include "proto.h"
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
27 #include <stdio.h>
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
29 int ScanSure(ADDR_T scanstart)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
30 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
31 ADDR_T address, addr;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
32 opcodes *instr;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
34 unsigned int size, counter;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
35 if (fVerbose)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
36 fprintf(stderr, "\n%s: scanning sure section $%04x", prog, scanstart);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
38 for (address = scanstart;; address += size)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
39 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
40 if (GetMemFlag(address)) /* rest of routine not valid */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
41 return ((Options & M_DATA_BLOCKS) == O_DBL_STRICT);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
43 instr = &opset[Memory[address]];
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
45 if (!instr->mnemonic) /* invalid opcode */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
46 return ((Options & M_DATA_BLOCKS) == O_DBL_STRICT);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
48 size = sizes[instr->admode];
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
49 if ((ADDR_T)(address + size - StartAddress) > (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
50 break; /* end of program code encountered */
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
52 switch (GetMemType(address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
53 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
54 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
55 return 0; /* The rest of the routine has already been processed. */
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
57 case MEM_DATA:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
58 AddEntry(address, scanstart, WRN_INSTR_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
59 break;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
61 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
62 AddEntry(address, scanstart, WRN_PARAM_JUMPED_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
63 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
65 SetMemType(address, MEM_INSTRUCTION);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
67 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: 14
diff changeset
68 switch
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
69 GetMemType(addr)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
70 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
71 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
72 AddEntry(addr, scanstart, WRN_PARAM_JUMPED_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
73 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
74 case MEM_DATA:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
75 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
76 /* fall through */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
77 default:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
78 SetMemType(addr, MEM_PARAMETER);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
79 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
81 if (instr->admode == zrel)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
82 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
83 addr = Memory[(ADDR_T)(address + 1)];
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
85 if (GetMemFlag(addr) && GetMemType(addr) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
86 return (Options & M_DATA_BLOCKS) == O_DBL_STRICT;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
88 if (((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress) || Options & B_LBL_ALWAYS))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
89 {
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
91 PutLabel(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
92 PutReference(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
93 PutLowByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
94 PutHighByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
95 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
96
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
97 addr = (ADDR_T)((int)(char)Memory[(ADDR_T)(address + 2)] + address + size);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
98 goto IsJump;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
99 }
9
987c90810883 Fix a warning.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
100
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
101 if (instr->admode == rel)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
102 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
103 addr = (ADDR_T)((int)(char)Memory[(ADDR_T)(address + 1)] + address + size);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
105 goto IsJump;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
106 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
107 if ((instr->mnemonic == S_JSR || instr->mnemonic == S_JMP) && instr->admode == abso)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
108 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
109 addr = Memory[(ADDR_T)(address + 1)] + (Memory[(ADDR_T)(address + 2)] << 8);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
111 IsJump:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
112 if (GetMemFlag(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
113 return ((Options & M_DATA_BLOCKS) == O_DBL_STRICT);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
115 if ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
116 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
117 if (GetMemType(addr) == MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
118 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
119 PutLabel(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
120 PutReference(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
121 PutLowByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
122 PutHighByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
123 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
124 else
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
125 AddEntry(addr, scanstart,
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
126 Options & B_SCEPTIC && instr->admode == rel && instr->mnemonic != S_BRA ? RTN_POTENTIAL
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
127 : RTN_SURE);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
128 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
129 else if (Options & B_LBL_ALWAYS)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
130 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
131 PutLabel(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
132 PutReference(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
133 PutLowByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
134 PutHighByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
135 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
137 if ((Options & M_DATA_BLOCKS) == O_DBL_STRICT && Options & B_JMP_STRICT && addr == address &&
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
138 instr->mnemonic != S_BVC)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
139 return 1;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
142 switch (instr->mnemonic)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
143 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
144 case S_JMP:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
145 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: 14
diff changeset
146
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
147 if (instr->admode == iabs && (ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
148 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
149 PutLabel(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
150 PutReference(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
151 PutLowByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
152 PutHighByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
153
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
154 /* Mark pointer as data. */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
155 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
156 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
157 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
158 SetMemType(addr, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
159 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
160 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
161 AddEntry(addr, scanstart, WRN_INSTR_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
162 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
163 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
164 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
165 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
166 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
167
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
168 addr++;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
169
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
170 if ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
171 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
172 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
173 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
174 SetMemType(addr, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
175 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
176 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
177 AddEntry(addr, scanstart, WRN_INSTR_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
178 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
179 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
180 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
181 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
182 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
183 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
184 else if (Options & B_LBL_ALWAYS)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
185 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
186 PutLabel(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
187 PutReference(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
188 PutLowByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
189 PutHighByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
190 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
191 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
192
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
193 case S_BRA:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
194 case S_RTS:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
195 case S_RTI:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
196 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
197
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
198 case S_BRK:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
199 case S_STP:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
200 return (Options & M_DATA_BLOCKS) == O_DBL_STRICT && Options & B_BRK_REJECT;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
201 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
202
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
203 if (instr->admode == rel)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
204 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
205 if ((ADDR_T)(addr - scanstart) >= (ADDR_T)(address - scanstart) || GetMemType(addr) != MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
206 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
207 if (GetMemType(address + size) != MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
208 AddEntry(address + size, scanstart, RTN_POTENTIAL);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
209
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
210 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
211 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
213 continue;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
214 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
215
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
216 if (instr->mnemonic == S_JSR)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
217 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
218 if (!(Options & B_STK_BALANCE))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
219 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
220 if (GetMemType(address + size) != MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
221 AddEntry(address + size, scanstart, RTN_POTENTIAL);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
222
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
223 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
224 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
225
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
226 continue;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
227 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
228
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
229 switch (size)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
230 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
231 case 2:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
232 addr = Memory[(ADDR_T)(address + 1)];
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
233 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
234 case 3:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
235 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: 14
diff changeset
236 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
237 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
238
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
239 if (types[instr->admode] != impimm && GetMemFlag(addr) && GetMemType(addr) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
240 return (Options & M_DATA_BLOCKS) == O_DBL_STRICT;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
241
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
242 if (types[instr->admode] != impimm &&
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
243 ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress) || Options & B_LBL_ALWAYS))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
244 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
245 PutLabel(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
246 PutReference(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
247 PutLowByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
248 PutHighByte(addr);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
249 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
250
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
251 if (types[instr->admode] != other && types[instr->admode] != impimm)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
252 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
253 if ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
254 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
255 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
256 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
257 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
258 SetMemType(addr, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
259 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
260 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
261 AddEntry(addr, scanstart, WRN_INSTR_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
262 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
263 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
264 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
265 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
266 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
267
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
268 if (types[instr->admode] == absindir)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
269 { /* indirect mode */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
270 addr++; /* set flags for upper vector byte */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
271
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
272 if ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
273 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
274 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
275 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
276 SetMemType(addr, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
277 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
278 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
279 AddEntry(addr, scanstart, WRN_INSTR_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
280 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
281 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
282 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
283 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
284 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
285 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
290 /* end of program (unexpectedly) encountered */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
291
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
292 if (Options & O_DBL_STRICT)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
293 return 1;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
294
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
295 AddEntry(EndAddress, scanstart, WRN_RTN_TRUNCATED);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
296 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
297 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
298
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
299 int ScanPotential(ADDR_T scanstart)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
300 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
301 ADDR_T address, addr;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
302 opcodes *instr;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
303
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
304 unsigned int size, counter;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
305
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
306 for (address = scanstart;; address += size)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
307 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
308 if (GetMemFlag(address)) /* rest of routine not valid */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
309 return 1;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
310
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
311 instr = &opset[Memory[address]];
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
312
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
313 if (!instr->mnemonic)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
314 { /* invalid opcode */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
315 SetMemFlag(address);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
317 if (GetMemType(address) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
318 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
319 return 1;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
320 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
321
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
322 size = sizes[instr->admode];
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
323 if ((ADDR_T)(address + size - StartAddress) > (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
324 break; /* end of program code encountered */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
325
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
326 if (GetMemType(address) == MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
327 return 0; /* The rest of the routine has already been processed. */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
328
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
329 if (instr->admode == zrel)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
330 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
331 addr = Memory[(ADDR_T)(address + 1)];
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
333 if (GetMemFlag(addr) && GetMemType(addr) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
334 goto Failure;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
335
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
336 if (((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress) || Options & B_LBL_ALWAYS))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
337 AddEntry(addr, scanstart, WRN_I_LABEL_NEEDED | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
338
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
339 addr = (ADDR_T)((int)(char)Memory[(ADDR_T)(address + 1)] + address + size);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
340
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
341 goto IsJump;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
342 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
343
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
344 if (instr->admode == rel)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
345 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
346 addr = (ADDR_T)((int)(char)Memory[(ADDR_T)(address + 1)] + address + size);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
347
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
348 goto IsJump;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
349 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
351 switch (size)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
352 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
353 case 2:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
354 addr = Memory[(ADDR_T)(address + 1)];
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
355 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
356 case 3:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
357 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: 14
diff changeset
358 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
359 default:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
360 addr = address;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
361 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
362
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
363 if (types[instr->admode] != impimm && GetMemFlag(addr) && GetMemType(addr) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
364 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
365 Failure:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
366 SetMemFlag(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
367
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
368 if (GetMemType(address) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
369 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
370 return 1;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
371 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
372
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
373 if ((instr->mnemonic == S_JSR || instr->mnemonic == S_JMP) && instr->admode == abso)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
374 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
375 IsJump:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
376 if (GetMemFlag(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
377 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
378 SetMemFlag(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
379
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
380 if (GetMemType(address) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
381 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
382 return 1;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
383 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
385 if ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
386 AddEntry(addr, scanstart,
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
387 Options & B_SCEPTIC && instr->admode == rel && instr->mnemonic != S_BRA ? RTN_SUSP_POT
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
388 : RTN_SUSPECTED);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
389 else if (Options & B_LBL_ALWAYS)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
390 AddEntry(addr, scanstart, WRN_I_LABEL_NEEDED | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
391
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
392 if (Options & B_JMP_STRICT && addr == address && instr->mnemonic != S_BVC)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
393 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
394 SetMemFlag(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
395
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
396 if (GetMemType(address) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
397 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
398 return 1;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
399 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
400 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
402 switch (instr->mnemonic)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
403 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
404 case S_BRK:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
405 case S_STP:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
406 if (Options & B_BRK_REJECT)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
407 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
408 SetMemFlag(address);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
410 if (GetMemType(address) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
411 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
412 return 1;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
413 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
414 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
415
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
416 if (!GetMemFlag(address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
417 switch (GetMemType(address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
418 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
419 case MEM_DATA:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
420 AddEntry(address, scanstart, WRN_INSTR_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
421 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
422
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
423 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
424 AddEntry(address, scanstart, WRN_PARAM_JUMPED_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
425 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
427 SetMemType(address, MEM_INSTRUCTION);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
428
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
429 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: 14
diff changeset
430 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
431 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
432 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
433 AddEntry(addr, scanstart, WRN_PARAM_JUMPED_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
434 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
435 case MEM_DATA:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
436 if (!GetMemFlag(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
437 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
438 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
439 default:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
440 SetMemType(addr, MEM_PARAMETER);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
441 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
442
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
443 switch (instr->mnemonic)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
444 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
445 case S_BRK:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
446 case S_STP:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
447 case S_RTS:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
448 case S_BRA:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
449 case S_RTI:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
450 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
451
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
452 case S_JMP:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
453 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: 14
diff changeset
454
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
455 if (instr->admode == iabs && (ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
456 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
457 AddEntry(addr, scanstart, WRN_I_LABEL_NEEDED | WRN_B_TEMPORARY);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
459 /* Mark pointer as data. */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
460 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
461 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
462 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
463 AddEntry(addr, scanstart, WRN_I_ACCESSED | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
464 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
465 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
466 AddEntry(addr, scanstart, WRN_INSTR_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
467 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
468 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
469 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
470 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
471 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
472
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
473 addr++;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
474
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
475 if ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
476 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
477 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
478 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
479 AddEntry(addr, scanstart, WRN_I_ACCESSED | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
480 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
481 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
482 AddEntry(addr, scanstart, WRN_INSTR_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
483 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
484 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
485 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
486 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
487 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
488 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
489 else if (Options & B_LBL_ALWAYS)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
490 AddEntry(addr, scanstart, WRN_I_LABEL_NEEDED | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
491
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
492 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
493 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
494
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
495 if (instr->admode == rel && GetMemType(address + size) != MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
496 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
497 AddEntry(address + size, scanstart, RTN_SUSP_POT);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
498
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
499 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
500 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
501
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
502 if (instr->mnemonic == S_JSR)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
503 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
504 if (!(Options & B_STK_BALANCE))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
505 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
506 if (GetMemType(address + size) != MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
507 AddEntry(address + size, scanstart, RTN_SUSP_POT);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
508
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
509 return 0;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
510 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
511
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
512 continue;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
513 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
514
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
515 switch (size)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
516 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
517 case 2:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
518 addr = Memory[(ADDR_T)(address + 1)];
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
519 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
520 case 3:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
521 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: 14
diff changeset
522 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
523 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
524
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
525 if (types[instr->admode] != impimm &&
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
526 ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress) || Options & B_LBL_ALWAYS))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
527 AddEntry(addr, scanstart, WRN_I_LABEL_NEEDED | WRN_B_TEMPORARY);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
528
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
529 if (types[instr->admode] != other && types[instr->admode] != impimm)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
530 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
531 if ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
532 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
533 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
534 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
535 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
536 AddEntry(addr, scanstart, WRN_I_ACCESSED | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
537 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
538 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
539 AddEntry(addr, scanstart, WRN_INSTR_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
540 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
541 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
542 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
543 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
544 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
546 if (types[instr->admode] == absindir)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
547 { /* indirect mode */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
548 addr++; /* set flags for upper vector byte */
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
550 if ((ADDR_T)(addr - StartAddress) < (ADDR_T)(EndAddress - StartAddress))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
551 switch (GetMemType(addr))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
552 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
553 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
554 AddEntry(addr, scanstart, WRN_I_ACCESSED | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
555 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
556 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
557 AddEntry(addr, scanstart, WRN_INSTR_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
558 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
559 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
560 AddEntry(addr, scanstart, WRN_PARAM_WRITTEN_TO | WRN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
561 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
562 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
563 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
564 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
565 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
567
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
568 /* end of program (unexpectedly) encountered */
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
569
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
570 return 1;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
571 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
572
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
573 int ScanSpecified(void)
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
574 {
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
575 table *entry;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
576
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
577 if (fVerbose)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
578 fprintf(stderr, "%s: scanning the routines at specified address(es)", prog);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
579
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
580 while ((entry = FindNextEntryType(NULL, ~0, RTN_SURE)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
581 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
582 PutLabel(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
583 PutReference(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
584 PutLowByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
585 PutHighByte(entry->address);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
586
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
587 if (ScanSure(entry->address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
588 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
589 fprintf(stderr, "For routine specified at %i:", (unsigned int)entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
590 return 1;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
591 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
592 entry = FindNextEntryType(NULL, ~0, RTN_SURE); // valgrind fart
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
593 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
594 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
595
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
596 return 0;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
597 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
598
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
599 void UnDoScan(ADDR_T scanstart)
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
600 {
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
601 opcodes *instr;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
602 unsigned counter;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
603 ADDR_T address;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
604
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
605 for (address = scanstart; address != EndAddress; address++)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
606 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
607 if (GetMemFlag(address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
608 return;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
609
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
610 switch (GetMemType(address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
611 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
612 case MEM_UNPROCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
613 return;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
614
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
615 case MEM_INSTRUCTION:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
616 SetMemFlag(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
617 SetMemType(address, MEM_DATA); /* This could cause WRN_PARAM_WRITTEN_TO
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
618 in vain. */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
619 instr = &opset[Memory[address++]];
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
620 for (counter = sizes[instr->admode]; --counter; address++)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
621 if (GetMemType(address) == MEM_PARAMETER)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
622 SetMemType(address, MEM_UNPROCESSED);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
623 else if (GetMemType(address) == MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
624 break;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
625
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
626 if (instr->mnemonic == S_STP || instr->mnemonic == S_BRK || instr->mnemonic == S_RTI ||
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
627 instr->mnemonic == S_RTS || instr->mnemonic == S_JMP || instr->admode == rel)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
628 return;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
629
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
630 address--;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
631 break;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
632
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
633 case MEM_PARAMETER:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
634 SetMemType(address, MEM_UNPROCESSED);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
635 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
636 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
637 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
638
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
639 void DeleteSuspectedParents(ADDR_T child)
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
640 {
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
641 table *entry = NULL;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
642
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
643 while ((entry = FindNextEntry(entry, child, ~(RTN_B_PROCESSED | RTN_B_TEMPORARY), RTN_SUSPECTED)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
644 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
645 if (entry->type & RTN_B_PROCESSED && entry->parent != child)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
646 DeleteSuspectedParents(entry->parent);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
647
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
648 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
649 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
650
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
651 entry = NULL;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
652
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
653 while ((entry = FindNextEntryTypeParent(entry, child, ~0, RTN_SUSP_POT)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
654 DeleteEntry(entry);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
655
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
656 entry = NULL;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
657
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
658 while ((entry = FindNextEntryTypeParent(entry, child, MASK_ANY | WRN_B_TEMPORARY, WRN_ANY | WRN_B_TEMPORARY)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
659 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
660 if (entry->type == (WRN_PARAM_JUMPED_TO | WRN_B_TEMPORARY))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
661 SetMemType(entry->address, MEM_PARAMETER);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
663 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
664 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
665
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
666 UnDoScan(child);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
667 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
668
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
669 void ScanPotentials(void)
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
670 {
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
671 table *entry;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
672 ADDR_T address;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
673
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
674 if (fVerbose)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
675 fprintf(stderr, "\n%s: scanning potential routines\n", prog);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
676
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
677 while ((entry = FindNextEntryType(NULL, ~0, RTN_POTENTIAL)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
678 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
679 address = entry->address;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
680 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
681
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
682 if (!ScanPotential(address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
683 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
684 while ((entry = FindNextEntryType(NULL, ~RTN_B_TEMPORARY, RTN_SUSPECTED)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
685 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
686 entry->type |= RTN_B_PROCESSED;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
687
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
688 if (ScanPotential(entry->address) && (Options & M_DATA_BLOCKS) != O_DBL_IGNORE)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
689 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
690 DeleteSuspectedParents(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
691 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
692 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
693 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
694
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
695 if (GetMemType(address) != MEM_DATA)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
696 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
697 PutLabel(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
698 PutLowByte(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
699 PutHighByte(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
700 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
701
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
702 entry = NULL;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
703
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
704 while ((entry = FindNextEntryType(entry, ~0, RTN_B_TEMPORARY | RTN_SUSPECTED | RTN_B_PROCESSED)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
705 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
706
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
707 entry = NULL;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
708
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
709 while ((entry = FindNextEntryType(entry, ~0, RTN_SUSPECTED | RTN_B_PROCESSED)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
710 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
711 PutLabel(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
712 PutReference(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
713 PutLowByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
714 PutHighByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
715 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
716 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
717
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
718 entry = NULL;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
719
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
720 while ((entry = FindNextEntryType(entry, ~0, RTN_SUSP_POT)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
721 entry->type = RTN_POTENTIAL;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
722
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
723 entry = NULL;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
724
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
725 while ((entry = FindNextEntryType(entry, MASK_ANY | WRN_B_TEMPORARY, WRN_ANY | WRN_B_TEMPORARY)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
726 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
727 switch (entry->type & ~WRN_B_TEMPORARY)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
728 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
729 case WRN_PARAM_WRITTEN_TO:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
730 if (GetMemType(entry->address) == MEM_DATA)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
731 SetMemType(entry->address, MEM_PARAMETER);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
732 entry->type &= ~WRN_B_TEMPORARY;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
733 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
734
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
735 case WRN_INSTR_WRITTEN_TO:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
736 if (GetMemType(entry->address) == MEM_DATA)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
737 SetMemType(entry->address, MEM_INSTRUCTION);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
738 entry->type &= ~WRN_B_TEMPORARY;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
739 break;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
740
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
741 case WRN_I_ACCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
742 SetMemType(entry->address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
743 /* fall through */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
744 case WRN_I_LABEL_NEEDED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
745 PutLabel(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
746 PutReference(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
747 PutLowByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
748 PutHighByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
749 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
750 break;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
751
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
752 default:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
753 entry->type &= ~WRN_B_TEMPORARY;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
754 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
755 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
756 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
757 else
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
758 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
759 DeleteSuspectedParents(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
760 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
761 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
762 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
763 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
764
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
765 void ScanTheRest(void)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
766 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
767 ADDR_T address;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
768 table *entry;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
769 unsigned int fPotentials;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
770
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
771 if ((Options & M_DATA_BLOCKS) == O_DBL_NOSCAN)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
772 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
773 for (address = StartAddress; address != EndAddress; address++)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
774 if (GetMemType(address) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
775 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
776
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
777 return;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
778 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
779
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
780 if (fVerbose)
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
781 fprintf(stderr, "%s: scanning the remaining bytes for routines\n", prog);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
782
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
783 for (address = StartAddress; address != EndAddress; address++)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
784 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
785 if (GetMemType(address) || GetMemFlag(address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
786 continue; /* scan only unprocessed bytes */
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
787
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
788 if (Options & B_RSC_STRICT)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
789 switch (opset[Memory[address]].mnemonic)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
790 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
791 case S_RTI:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
792 case S_RTS:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
793 case S_BRK:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
794 case S_STP:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
795 continue;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
796
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
797 case S_BRA:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
798 break;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
799
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
800 default:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
801 if (opset[Memory[address]].admode == rel && GetMemType(address + sizes[rel]) != MEM_INSTRUCTION)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
802 AddEntry(address + sizes[rel], address, RTN_SUSPECTED | RTN_B_TEMPORARY);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
803 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
804
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
805 if (fVerbose)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
806 fprintf(stderr, "\n%s: scanning at $%04x", prog, address);
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
807
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
808 if (!ScanPotential(address))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
809 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
810 while ((entry = FindNextEntryType(NULL, ~RTN_B_TEMPORARY, RTN_SUSPECTED)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
811 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
812 entry->type |= RTN_B_PROCESSED;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
813
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
814 if (ScanPotential(entry->address) && (Options & M_DATA_BLOCKS) != O_DBL_IGNORE)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
815 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
816 DeleteSuspectedParents(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
817 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
818 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
819 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
820
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
821 if (GetMemType(address) != MEM_DATA)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
822 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
823 PutLabel(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
824 PutReference(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
825 PutLowByte(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
826 PutHighByte(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
827 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
828
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
829 fPotentials = FALSE;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
830 entry = NULL;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
831
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
832 while ((entry = FindNextEntryType(entry, ~0, RTN_SUSP_POT)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
833 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
834 fPotentials = TRUE;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
835 entry->type = RTN_POTENTIAL;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
836 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
837
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
838 entry = NULL;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
839
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
840 while ((entry = FindNextEntryType(entry, ~0, RTN_B_TEMPORARY | RTN_SUSPECTED | RTN_B_PROCESSED)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
841 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
842
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
843 entry = NULL;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
844
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
845 while ((entry = FindNextEntryType(entry, ~0, RTN_SUSPECTED | RTN_B_PROCESSED)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
846 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
847 PutLabel(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
848 PutReference(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
849 PutLowByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
850 PutHighByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
851 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
852 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
853
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
854 entry = NULL;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
855
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
856 while ((entry = FindNextEntryType(entry, MASK_ANY | WRN_B_TEMPORARY, WRN_ANY | WRN_B_TEMPORARY)))
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
857 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
858 switch (entry->type & ~WRN_B_TEMPORARY)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
859 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
860 case WRN_PARAM_WRITTEN_TO:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
861 if (GetMemType(entry->address) == MEM_DATA)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
862 SetMemType(entry->address, MEM_PARAMETER);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
863 entry->type &= ~WRN_B_TEMPORARY;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
864 break;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
865
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
866 case WRN_INSTR_WRITTEN_TO:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
867 if (GetMemType(entry->address) == MEM_DATA)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
868 SetMemType(entry->address, MEM_INSTRUCTION);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
869 entry->type &= ~WRN_B_TEMPORARY;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
870 break;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
871
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
872 case WRN_I_ACCESSED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
873 SetMemType(entry->address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
874 /* fall through */
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
875 case WRN_I_LABEL_NEEDED:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
876 PutLabel(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
877 PutReference(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
878 PutLowByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
879 PutHighByte(entry->address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
880 DeleteEntry(entry);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
881 break;
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
882
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
883 default:
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
884 entry->type &= ~WRN_B_TEMPORARY;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
885 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
886 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
887
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
888 if (fPotentials)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
889 ScanPotentials();
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
890 }
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
891 else
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
892 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
893 DeleteSuspectedParents(address);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
894 SetMemType(address, MEM_DATA);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
895 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
896 }
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
897
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
898 if (fVerbose)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
899 fprintf(stderr, "\n");
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
900
16
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
901 for (address = StartAddress; address != EndAddress; address++)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
902 if (GetMemType(address) == MEM_UNPROCESSED)
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
903 {
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
904 fPotentials = GetMemFlag(address) ? MEM_PARAMETER : MEM_DATA;
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
905 SetMemType(address, fPotentials);
a2a81589380d Reformat the whole source via clang-format for better consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
906 }
0
4410c9c7750d Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
907 }