diff --git a/AssemblerWarnings.Groups.cs b/AssemblerWarnings.Groups.cs index 717c62f..9e2689b 100644 --- a/AssemblerWarnings.Groups.cs +++ b/AssemblerWarnings.Groups.cs @@ -480,6 +480,22 @@ public partial class AssemblerWarnings { new Opcode(0x03, 0x30), new Opcode(0x03, 0x31), new Opcode(0x03, 0x32), }; + /// + /// All instructions that always read a single byte from a pointer - regardless of its read size. + /// The pointer is always the first operand. + /// + internal static readonly HashSet pointerSingleByte = new() + { + new Opcode(0x00, 0xC7), + new Opcode(0x00, 0xCB), + new Opcode(0x00, 0xCF), + new Opcode(0x00, 0xD7), + new Opcode(0x00, 0xDB), + new Opcode(0x00, 0xDF), + + new Opcode(0x01, 0x57), + new Opcode(0x01, 0x67), + }; /// /// Directives that result in data (non-code bytes) being inserted into the assembly. diff --git a/AssemblerWarnings.Messages.cs b/AssemblerWarnings.Messages.cs index 0ed6841..8de5b28 100644 --- a/AssemblerWarnings.Messages.cs +++ b/AssemblerWarnings.Messages.cs @@ -54,7 +54,8 @@ public partial class AssemblerWarnings { 0032, Strings_AssemblerWarnings.Warning_0032 }, { 0033, Strings_AssemblerWarnings.Warning_0033 }, { 0034, Strings_AssemblerWarnings.Warning_0034 }, - { 0035, Strings_AssemblerWarnings.Warning_0035 } + { 0035, Strings_AssemblerWarnings.Warning_0035 }, + { 0036, Strings_AssemblerWarnings.Warning_0036 }, }; [Localizable(true)] diff --git a/AssemblerWarnings.cs b/AssemblerWarnings.cs index ec74002..0b59909 100644 --- a/AssemblerWarnings.cs +++ b/AssemblerWarnings.cs @@ -261,6 +261,7 @@ public AssemblerWarnings(bool usingV1Format) { 0033, Analyzer_Rolling_Warning_0033 }, { 0034, Analyzer_Rolling_Warning_0034 }, { 0035, Analyzer_Rolling_Warning_0035 }, + { 0036, Analyzer_Rolling_Warning_0036 }, #endif }; suggestionRollingAnalyzers = new Dictionary @@ -900,6 +901,13 @@ private bool Analyzer_Rolling_Warning_0035() return newBytes.Length > 0 && !instructionIsData && moveInstructionPointerReadSizes.TryGetValue(instructionOpcode, out PointerReadSize readSize) && Assembler.ParsePointer(operands[1]).ReadSize != readSize; } + + private bool Analyzer_Rolling_Warning_0036() + { + // Warning 0036: Pointer size other than 8 bits (`B*`) used in a context where a single byte will always be read. + return newBytes.Length > 0 && !instructionIsData && pointerSingleByte.Contains(instructionOpcode) + && Assembler.ParsePointer(operands[0]).ReadSize != PointerReadSize.Byte; + } #endif private bool Analyzer_Rolling_Suggestion_0001() diff --git a/Example Programs/AoC-2022/D10.asm b/Example Programs/AoC-2022/D10.asm index f9d1e9e..cfaa225 100644 --- a/Example Programs/AoC-2022/D10.asm +++ b/Example Programs/AoC-2022/D10.asm @@ -57,7 +57,7 @@ MVQ rg7, :&PART_TWO_RESULT :PART_TWO_PRINT_LOOP CMP rg7, rg4 JGE :END -WCC *rg7 +WCC B*rg7 ICR rg7 JMP :PART_TWO_PRINT_LOOP :END diff --git a/Example Programs/bitmap.ext.asm b/Example Programs/bitmap.ext.asm index 5e84d38..b9fc90e 100644 --- a/Example Programs/bitmap.ext.asm +++ b/Example Programs/bitmap.ext.asm @@ -217,7 +217,7 @@ MVQ rg4, rg3 :FUNC_BITMAP_ENCODE_FILE_WRITE_LOOP CMP rg4, rg0 JGE :FUNC_BITMAP_ENCODE_FILE_WRITE_LOOP_END -WFC *rg4 +WFC B*rg4 ICR rg4 JMP :FUNC_BITMAP_ENCODE_FILE_WRITE_LOOP :FUNC_BITMAP_ENCODE_FILE_WRITE_LOOP_END diff --git a/Resources/Localization/Strings.AssemblerWarnings.Designer.cs b/Resources/Localization/Strings.AssemblerWarnings.Designer.cs index f39132c..9cf3dc7 100644 --- a/Resources/Localization/Strings.AssemblerWarnings.Designer.cs +++ b/Resources/Localization/Strings.AssemblerWarnings.Designer.cs @@ -662,5 +662,14 @@ internal static string Warning_0035 { return ResourceManager.GetString("Warning_0035", resourceCulture); } } + + /// + /// Looks up a localized string similar to Pointer size other than 8 bits (`B*`) used in a context where a single byte will always be read.. + /// + internal static string Warning_0036 { + get { + return ResourceManager.GetString("Warning_0036", resourceCulture); + } + } } } diff --git a/Resources/Localization/Strings.AssemblerWarnings.resx b/Resources/Localization/Strings.AssemblerWarnings.resx index 80494af..7c693af 100644 --- a/Resources/Localization/Strings.AssemblerWarnings.resx +++ b/Resources/Localization/Strings.AssemblerWarnings.resx @@ -240,4 +240,7 @@ Pointer read size does not match the size of this move instruction. The pointer read size will be ignored. + + Pointer size other than 8 bits (`B*`) used in a context where a single byte will always be read. + \ No newline at end of file