diff --git a/SourceGen/DisasmProject.cs b/SourceGen/DisasmProject.cs index 7a87a46..2effea4 100644 --- a/SourceGen/DisasmProject.cs +++ b/SourceGen/DisasmProject.cs @@ -664,6 +664,22 @@ namespace SourceGen { } } + private void ValidateAddressMap() { + foreach (AddressMap.AddressMapEntry entry in AddrMap) { + if ((entry.Addr & 0xff0000) != ((entry.Addr + entry.Length - 1) & 0xff0000)) { + string fmt = Res.Strings.MSG_BANK_OVERRUN_DETAIL_FMT; + int firstNext = (entry.Addr & 0xff0000) + 0x010000; + int badOffset = entry.Offset + (firstNext - entry.Addr); + Messages.Add(new MessageList.MessageEntry( + MessageList.MessageEntry.SeverityLevel.Error, + entry.Offset, + MessageList.MessageEntry.MessageType.BankOverrun, + string.Format(fmt, "+" + badOffset.ToString("x6")), + MessageList.MessageEntry.ProblemResolution.None)); + } + } + } + #region Analysis /// @@ -809,6 +825,7 @@ namespace SourceGen { Validate(); reanalysisTimer.EndTask("Validate"); #endif + ValidateAddressMap(); reanalysisTimer.EndTask("DisasmProject.Analyze()"); //reanalysisTimer.DumpTimes("DisasmProject timers:", debugLog); diff --git a/SourceGen/MessageList.cs b/SourceGen/MessageList.cs index 30c9147..4df60ed 100644 --- a/SourceGen/MessageList.cs +++ b/SourceGen/MessageList.cs @@ -52,6 +52,7 @@ namespace SourceGen { UnresolvedWeakRef, InvalidOffsetOrLength, InvalidDescriptor, + BankOverrun, } public MessageType MsgType { get; private set; } @@ -163,6 +164,9 @@ namespace SourceGen { case MessageEntry.MessageType.InvalidDescriptor: problem = Res.Strings.MSG_INVALID_DESCRIPTOR; break; + case MessageEntry.MessageType.BankOverrun: + problem = Res.Strings.MSG_BANK_OVERRUN; + break; default: problem = "???"; break; diff --git a/SourceGen/Res/Strings.xaml b/SourceGen/Res/Strings.xaml index 945d675..911ddf1 100644 --- a/SourceGen/Res/Strings.xaml +++ b/SourceGen/Res/Strings.xaml @@ -107,6 +107,8 @@ limitations under the License. Unable to format as word: each selected region must have an even number of bytes ({0} region(s) are selected). • Clear variables • Empty variable table + Address bank overrun + Bank boundary crossed at offset {0} Format ignored Hidden label Hidden variable table diff --git a/SourceGen/Res/Strings.xaml.cs b/SourceGen/Res/Strings.xaml.cs index 31ddbe8..eb3e5ea 100644 --- a/SourceGen/Res/Strings.xaml.cs +++ b/SourceGen/Res/Strings.xaml.cs @@ -195,6 +195,10 @@ namespace SourceGen.Res { (string)Application.Current.FindResource("str_LocalVariableTableClear"); public static string LOCAL_VARIABLE_TABLE_EMPTY = (string)Application.Current.FindResource("str_LocalVariableTableEmpty"); + public static string MSG_BANK_OVERRUN = + (string)Application.Current.FindResource("str_MsgBankOverrun"); + public static string MSG_BANK_OVERRUN_DETAIL_FMT = + (string)Application.Current.FindResource("str_MsgBankOverrunDetailFmt"); public static string MSG_FORMAT_DESCRIPTOR_IGNORED = (string)Application.Current.FindResource("str_MsgFormatDescriptorIgnored"); public static string MSG_HIDDEN_LABEL =