diff --git a/SourceGen/DisasmProject.cs b/SourceGen/DisasmProject.cs index e73f15a..b32b77d 100644 --- a/SourceGen/DisasmProject.cs +++ b/SourceGen/DisasmProject.cs @@ -532,20 +532,29 @@ namespace SourceGen { } if (mAnattribs[offset].IsInstructionStart) { - // Check length for instruction formatters. + // Check length for instruction formatters. This can happen if you format + // a bunch of bytes as single-byte data items and then add a code entry + // point. if (kvp.Value.Length != mAnattribs[offset].Length) { - genLog.LogW("Unexpected length on instr format descriptor (" + + genLog.LogW("+" + offset.ToString("x6") + + ": unexpected length on instr format descriptor (" + kvp.Value.Length + " vs " + mAnattribs[offset].Length + ")"); continue; // ignore this one } + if (kvp.Value.Length == 1) { + // No operand to format! + genLog.LogW("+" + offset.ToString("x6") + + ": unexpected format descriptor on single-byte op"); + continue; // ignore this one + } if (!kvp.Value.IsValidForInstruction) { genLog.LogW("Descriptor not valid for instruction: " + kvp.Value); continue; // ignore this one } } else if (mAnattribs[offset].IsInstruction) { // Mid-instruction format. - genLog.LogW("Unexpected mid-instruction format descriptor at +" + - offset.ToString("x6")); + genLog.LogW("+" + offset.ToString("x6") + + ": unexpected mid-instruction format descriptor"); continue; // ignore this one } diff --git a/SourceGen/DisplayList.cs b/SourceGen/DisplayList.cs index 4d2858e..ba0086f 100644 --- a/SourceGen/DisplayList.cs +++ b/SourceGen/DisplayList.cs @@ -1096,8 +1096,11 @@ namespace SourceGen { operandForSymbol = attr.OperandAddress; } - // Check Length to watch for bogus descriptors (?) + // Check Length to watch for bogus descriptors. ApplyFormatDescriptors() should + // have discarded anything appropriate, so we might be able to eliminate this test. if (attr.DataDescriptor != null && attr.Length == attr.DataDescriptor.Length) { + Debug.Assert(operandLen > 0); + // Format operand as directed. if (op.AddrMode == OpDef.AddressMode.BlockMove) { // Special handling for the double-operand block move.