1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-05-31 22:41:37 +00:00

Remove a couple of faulty assertions

One asserted unnecessarily, one should have been an if/then.  Both
were concerned with instruction operands being formatted with
type "address".
This commit is contained in:
Andy McFadden 2021-08-11 16:25:24 -07:00
parent 635084db9d
commit ec2ad529c8
2 changed files with 34 additions and 25 deletions

View File

@ -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;
}

View File

@ -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));
}
}
}