mirror of
https://github.com/fadden/6502bench.git
synced 2025-02-09 11:31:24 +00:00
Minor tweaks
This commit is contained in:
parent
ee6e5d7fb6
commit
8727d49f43
@ -218,8 +218,8 @@ namespace SourceGen {
|
||||
public int Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Instructions: length of the instruction (for InstrStart). If a FormatDescriptor
|
||||
/// is assigned, the length must match.
|
||||
/// Instructions: length of the instruction (for InstrStart). If a FormatDescriptor is
|
||||
/// assigned, the length must match, or the dfd will be ignored.
|
||||
/// Inline data: FormatDescriptor length, or zero if no descriptor is defined.
|
||||
/// Data: FormatDescriptor length, or zero if no descriptor is defined.
|
||||
///
|
||||
|
@ -581,6 +581,58 @@ namespace SourceGen {
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks some stuff. Problems are handled with assertions, so this is only
|
||||
/// useful in debug builds.
|
||||
/// </summary>
|
||||
public void Validate() {
|
||||
// Confirm that we can walk through the file, stepping directly from the start
|
||||
// of one thing to the start of the next.
|
||||
int offset = 0;
|
||||
while (offset < mFileData.Length) {
|
||||
Anattrib attr = mAnattribs[offset];
|
||||
bool thisIsCode = attr.IsInstructionStart;
|
||||
Debug.Assert(attr.IsStart);
|
||||
Debug.Assert(attr.Length != 0);
|
||||
offset += attr.Length;
|
||||
|
||||
// Sometimes embedded instructions continue past the "outer" instruction,
|
||||
// usually because we're misinterpreting the code. We need to deal with
|
||||
// that here.
|
||||
int extraInstrBytes = 0;
|
||||
while (offset < mFileData.Length && mAnattribs[offset].IsInstruction &&
|
||||
!mAnattribs[offset].IsInstructionStart) {
|
||||
extraInstrBytes++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
// Make sure the extra code bytes were part of an instruction. Otherwise it
|
||||
// means we moved from the end of a data area to the middle of an instruction,
|
||||
// which is very bad.
|
||||
Debug.Assert(extraInstrBytes == 0 || thisIsCode);
|
||||
|
||||
//if (extraInstrBytes > 0) { Debug.WriteLine("EIB=" + extraInstrBytes); }
|
||||
// Max instruction len is 4, so the stray part must be shorter.
|
||||
Debug.Assert(extraInstrBytes < 4);
|
||||
}
|
||||
Debug.Assert(offset == mFileData.Length);
|
||||
|
||||
// Confirm that all bytes are tagged as code, data, or inline data. The Asserts
|
||||
// in Anattrib should confirm that nothing is tagged as more than one thing.
|
||||
for (offset = 0; offset < mAnattribs.Length; offset++) {
|
||||
Anattrib attr = mAnattribs[offset];
|
||||
Debug.Assert(attr.IsInstruction || attr.IsInlineData || attr.IsData);
|
||||
}
|
||||
|
||||
// Confirm that there are no Default format entries in OperandFormats.
|
||||
foreach (KeyValuePair<int, FormatDescriptor> kvp in OperandFormats) {
|
||||
Debug.Assert(kvp.Value.FormatType != FormatDescriptor.Type.Default);
|
||||
Debug.Assert(kvp.Value.FormatType != FormatDescriptor.Type.REMOVE);
|
||||
}
|
||||
}
|
||||
|
||||
#region Analysis
|
||||
|
||||
/// <summary>
|
||||
/// Analyzes the file data. This is the main entry point for code/data analysis.
|
||||
/// </summary>
|
||||
@ -1298,55 +1350,10 @@ namespace SourceGen {
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks some stuff. Problems are handled with assertions, so this is only
|
||||
/// useful in debug builds.
|
||||
/// </summary>
|
||||
public void Validate() {
|
||||
// Confirm that we can walk through the file, stepping directly from the start
|
||||
// of one thing to the start of the next.
|
||||
int offset = 0;
|
||||
while (offset < mFileData.Length) {
|
||||
Anattrib attr = mAnattribs[offset];
|
||||
bool thisIsCode = attr.IsInstructionStart;
|
||||
Debug.Assert(attr.IsStart);
|
||||
Debug.Assert(attr.Length != 0);
|
||||
offset += attr.Length;
|
||||
#endregion Analysis
|
||||
|
||||
// Sometimes embedded instructions continue past the "outer" instruction,
|
||||
// usually because we're misinterpreting the code. We need to deal with
|
||||
// that here.
|
||||
int extraInstrBytes = 0;
|
||||
while (offset < mFileData.Length && mAnattribs[offset].IsInstruction &&
|
||||
!mAnattribs[offset].IsInstructionStart) {
|
||||
extraInstrBytes++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
// Make sure the extra code bytes were part of an instruction. Otherwise it
|
||||
// means we moved from the end of a data area to the middle of an instruction,
|
||||
// which is very bad.
|
||||
Debug.Assert(extraInstrBytes == 0 || thisIsCode);
|
||||
|
||||
//if (extraInstrBytes > 0) { Debug.WriteLine("EIB=" + extraInstrBytes); }
|
||||
// Max instruction len is 4, so the stray part must be shorter.
|
||||
Debug.Assert(extraInstrBytes < 4);
|
||||
}
|
||||
Debug.Assert(offset == mFileData.Length);
|
||||
|
||||
// Confirm that all bytes are tagged as code, data, or inline data. The Asserts
|
||||
// in Anattrib should confirm that nothing is tagged as more than one thing.
|
||||
for (offset = 0; offset < mAnattribs.Length; offset++) {
|
||||
Anattrib attr = mAnattribs[offset];
|
||||
Debug.Assert(attr.IsInstruction || attr.IsInlineData || attr.IsData);
|
||||
}
|
||||
|
||||
// Confirm that there are no Default format entries in OperandFormats.
|
||||
foreach (KeyValuePair<int, FormatDescriptor> kvp in OperandFormats) {
|
||||
Debug.Assert(kvp.Value.FormatType != FormatDescriptor.Type.Default);
|
||||
Debug.Assert(kvp.Value.FormatType != FormatDescriptor.Type.REMOVE);
|
||||
}
|
||||
}
|
||||
#region Change Management
|
||||
|
||||
/// <summary>
|
||||
/// Generates a ChangeSet that merges the FormatDescriptors in the new list into
|
||||
@ -1978,6 +1985,8 @@ namespace SourceGen {
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Change Management
|
||||
|
||||
/// <summary>
|
||||
/// Finds a label by name. SymbolTable must be populated.
|
||||
/// </summary>
|
||||
|
@ -3267,6 +3267,12 @@ namespace SourceGen {
|
||||
// If the descriptor has a weak reference to an unknown symbol, should we
|
||||
// call that out here?
|
||||
sb.AppendFormat(Res.Strings.INFO_FD_SUM_FMT, dfd.ToUiString());
|
||||
|
||||
// If the format descriptor for an instruction has the wrong length, it will
|
||||
// be ignored. Call that out.
|
||||
if (attr.IsInstructionStart && attr.Length != dfd.Length) {
|
||||
sb.AppendFormat(" [incorrect format length]");
|
||||
}
|
||||
}
|
||||
sb.Append("\r\n");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user