diff --git a/source2/Compiler/Cosmos.XSharp/TokenList.cs b/source2/Compiler/Cosmos.XSharp/TokenList.cs index 908f822bb..d88150ac6 100644 --- a/source2/Compiler/Cosmos.XSharp/TokenList.cs +++ b/source2/Compiler/Cosmos.XSharp/TokenList.cs @@ -40,7 +40,7 @@ namespace Cosmos.Compiler.XSharp { for (int i = 0; i < aObj.Count; i++) { var xThis = this[i]; var xThat = aObj[i]; - if (xThis.Type != aObj[i].Type) { + if (xThis.Type != xThat.Type) { return false; } else if (xThis.Type == TokenType.AlphaNum || xThat.Type == TokenType.Keyword) { if (xThis.Value == null || aObj[i].Value == null) { @@ -48,6 +48,37 @@ namespace Cosmos.Compiler.XSharp { return false; } } else if (xThis.Type == TokenType.Register) { + string xThisUpper = xThis.Value.ToUpper(); + string xThatUpper = xThat.Value.ToUpper(); + + if (xThisUpper == "_REG" || xThatUpper == "_REG") { + // true, ie continue + + } else if (xThisUpper == "_REG8" && xThatUpper == "_REG8") { + return false; + } else if (xThisUpper == "_REG8" && Parser.Registers8.Contains(xThatUpper)) { + return false; + } else if (xThatUpper == "_REG8" && Parser.Registers8.Contains(xThisUpper)) { + return false; + + } else if (xThisUpper == "_REG16" && xThatUpper == "_REG16") { + return false; + } else if (xThisUpper == "_REG16" && Parser.Registers8.Contains(xThatUpper)) { + return false; + } else if (xThatUpper == "_REG16" && Parser.Registers8.Contains(xThisUpper)) { + return false; + + } else if (xThisUpper == "_REG32" && xThatUpper == "_REG32") { + return false; + } else if (xThisUpper == "_REG32" && Parser.Registers8.Contains(xThatUpper)) { + return false; + } else if (xThatUpper == "_REG32" && Parser.Registers8.Contains(xThisUpper)) { + return false; + + } else if (xThisUpper != xThatUpper) { + // Must be last, after patterns + return false; + } } }