mirror of
https://github.com/fadden/6502bench.git
synced 2025-11-05 16:17:24 +00:00
Disregard operand address, part 1
SourceGen puts a lot of effort into connecting address operands to internal offsets and external symbols. Sometimes this is undesirable. For example, a BIT or conditional branch instruction is sometimes used as a dummy when there are multiple entry points that vary only in a status flag or register value. The address in the BIT or branch is either irrelevant or never actually referenced, so auto-generating a label for it is annoying. Having a way to tell the disassembler to disregard an address operand, so that it won't generate an auto-label or be included in the list of cross-references, provides a simple solution to this. The operand's file offset is determined during the code analysis pass. Setting it to -1 makes the operand look like an external address. If we disable the project/platform symbol lookup for that instruction as well, we can avoid label generation and cross-references. We also need to prevent the 65816 data bank fixup code from restoring it, and the relocation data code from doing its thing. The flag is implemented as a new "misc flags" table, which holds a set of bit flags for every file offset. The "disregard operand address" flag is set on the opcode byte of instructions. The flags are expected to be used infrequently, so they're currently output as a list of (offset, integer) pairs. The flag is set in the Edit Instruction Operand dialog, which has a new checkbox. The checkbox is disabled for immediate operands. (issue #174)
This commit is contained in:
@@ -56,7 +56,7 @@ namespace SourceGen {
|
||||
// ignore stuff that's in one side but not the other. However, if we're opening a
|
||||
// newer file in an older program, it's worth letting the user know that some stuff
|
||||
// may get lost as soon as they save the file.
|
||||
public const int CONTENT_VERSION = 6;
|
||||
public const int CONTENT_VERSION = 7;
|
||||
|
||||
// Max JSON file length.
|
||||
internal const int MAX_JSON_LENGTH = 64 * 1024 * 1024;
|
||||
@@ -470,6 +470,7 @@ namespace SourceGen {
|
||||
public List<SerAddressMapEntry> AddressMap { get; set; }
|
||||
public List<SerTypeHintRange> TypeHints { get; set; }
|
||||
public Dictionary<string, int> StatusFlagOverrides { get; set; }
|
||||
public Dictionary<string, int> MiscFlags { get; set; }
|
||||
public Dictionary<string, string> Comments { get; set; }
|
||||
public Dictionary<string, SerMultiLineComment> LongComments { get; set; }
|
||||
public Dictionary<string, SerMultiLineComment> Notes { get; set; }
|
||||
@@ -533,6 +534,16 @@ namespace SourceGen {
|
||||
spf.StatusFlagOverrides.Add(i.ToString(), proj.StatusFlagOverrides[i].AsInt);
|
||||
}
|
||||
|
||||
// Write flags as an integer. A string of enumerations would have some advantages,
|
||||
// but simplicity is not among them.
|
||||
spf.MiscFlags = new Dictionary<string, int>();
|
||||
for (int i = 0; i < proj.MiscFlags.Length; i++) {
|
||||
if (proj.MiscFlags[i] == DisasmProject.MiscFlag.None) {
|
||||
continue;
|
||||
}
|
||||
spf.MiscFlags.Add(i.ToString(), (int)proj.MiscFlags[i]);
|
||||
}
|
||||
|
||||
// Convert Comments to serializable form.
|
||||
spf.Comments = new Dictionary<string, string>();
|
||||
for (int i = 0; i < proj.Comments.Length; i++) {
|
||||
@@ -761,7 +772,7 @@ namespace SourceGen {
|
||||
}
|
||||
|
||||
// Deserialize status flag overrides.
|
||||
foreach (KeyValuePair<string,int> kvp in spf.StatusFlagOverrides) {
|
||||
foreach (KeyValuePair<string, int> kvp in spf.StatusFlagOverrides) {
|
||||
if (!ParseValidateKey(kvp.Key, spf.FileDataLength,
|
||||
Res.Strings.PROJECT_FIELD_STATUS_FLAGS, report, out int intKey)) {
|
||||
continue;
|
||||
@@ -961,6 +972,16 @@ namespace SourceGen {
|
||||
}
|
||||
}
|
||||
|
||||
// Deserialize misc flags. These were added in 1.10.
|
||||
if (spf.MiscFlags != null) {
|
||||
foreach (KeyValuePair<string, int> kvp in spf.MiscFlags) {
|
||||
if (!ParseValidateKey(kvp.Key, spf.FileDataLength,
|
||||
Res.Strings.PROJECT_FIELD_MISC_FLAGS, report, out int intKey)) {
|
||||
continue;
|
||||
}
|
||||
proj.MiscFlags[intKey] = (DisasmProject.MiscFlag)kvp.Value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user