diff --git a/SourceGen/DataAnalysis.cs b/SourceGen/DataAnalysis.cs index cd92601..e36e42b 100644 --- a/SourceGen/DataAnalysis.cs +++ b/SourceGen/DataAnalysis.cs @@ -157,8 +157,14 @@ namespace SourceGen { // numeric/Address, but we don't allow that for instructions.) // // Project and platform symbols are applied later. - Debug.Assert(attr.DataDescriptor.FormatSubType != - FormatDescriptor.SubType.Address); + + // (This assert is bogus -- this is possible with a bad bit of formatting. + // One way this can occur semi-naturally is to follow a JSR with a 16-bit + // value that evaluates to a pair of "illegal" instructions, which are + // then formatted by the user as a 16-bit address without tagging as + // inline data. Enabling undocumented 6502 instructions throws it off.) + //Debug.Assert(attr.DataDescriptor.FormatSubType != + // FormatDescriptor.SubType.Address); continue; } diff --git a/SourceGen/DisasmProject.cs b/SourceGen/DisasmProject.cs index 80e79c7..deaf04a 100644 --- a/SourceGen/DisasmProject.cs +++ b/SourceGen/DisasmProject.cs @@ -1649,30 +1649,33 @@ namespace SourceGen { MessageList.MessageEntry.ProblemResolution.FormatDescriptorIgnored)); } } else if (dfd.FormatSubType == FormatDescriptor.SubType.Address) { - // not expecting this format on an instruction operand - Debug.Assert(attr.IsData || attr.IsInlineData); - - // This generally doesn't happen for internal addresses, because - // we create an auto label for the target address, and a weak ref - // to the auto label, which means the xref is handled by the symbol - // code above. This case really only happens for external addresses, - // which either have a label (because we defined a symbol) and got - // handled earlier, or don't have a label and aren't useful for a - // cross-reference. - // - // There might be a case I'm missing, so I'm going to take a swing - // at it and spit out a debug message either way. - int operandAddr = RawData.GetWord(mFileData, offset, - dfd.Length, dfd.FormatType == FormatDescriptor.Type.NumericBE); - int targetOffset = AddrMap.AddressToOffset(offset, operandAddr); - if (targetOffset < 0) { - Debug.WriteLine("No xref for addr $" + operandAddr.ToString("x4") + - " at +" + offset.ToString("x6")); - } else { - Debug.WriteLine("HEY: found unlabeled addr ref at +" + + if (!(attr.IsData || attr.IsInlineData)) { + // not expecting this format on an instruction operand + Debug.WriteLine("Found addr format on instruction at +" + offset.ToString("x6")); - AddXref(targetOffset, new XrefSet.Xref(offset, false, xrefType, - accType, accessFlags, 0)); + } else { + // This generally doesn't happen for internal addresses, because + // we create an auto label for the target address, and a weak ref + // to the auto label, which means the xref is handled by the symbol + // code above. This case really only happens for external addresses, + // which either have a label (because we defined a symbol) and got + // handled earlier, or don't have a label and aren't useful for a + // cross-reference. + // + // There might be a case I'm missing, so I'm going to take a swing + // at it and spit out a debug message either way. + int operandAddr = RawData.GetWord(mFileData, offset, + dfd.Length, dfd.FormatType == FormatDescriptor.Type.NumericBE); + int targetOffset = AddrMap.AddressToOffset(offset, operandAddr); + if (targetOffset < 0) { + Debug.WriteLine("No xref for addr $" + operandAddr.ToString("x4") + + " at +" + offset.ToString("x6")); + } else { + Debug.WriteLine("HEY: found unlabeled addr ref at +" + + offset.ToString("x6")); + AddXref(targetOffset, new XrefSet.Xref(offset, false, xrefType, + accType, accessFlags, 0)); + } } }