diff --git a/src/HexManiac.Core/Models/Code/ThumbParser.cs b/src/HexManiac.Core/Models/Code/ThumbParser.cs index 991ec579..c096a08b 100644 --- a/src/HexManiac.Core/Models/Code/ThumbParser.cs +++ b/src/HexManiac.Core/Models/Code/ThumbParser.cs @@ -505,7 +505,7 @@ namespace HavenSoft.HexManiac.Core.Models.Code { // read a number if (template[0] == '#') { if (line[0] != '#') return false; - if (!int.TryParse(line.Substring(1), out numeric)) return false; + if (!int.TryParse(line.Split(',', ']')[0].Substring(1), out numeric)) return false; template = template.Substring(1); line = line.Substring(("#" + numeric).Length); continue; diff --git a/src/HexManiac.Tests/ToolTests.cs b/src/HexManiac.Tests/ToolTests.cs index c1099800..58355bf4 100644 --- a/src/HexManiac.Tests/ToolTests.cs +++ b/src/HexManiac.Tests/ToolTests.cs @@ -390,6 +390,7 @@ namespace HavenSoft.HexManiac.Tests { [InlineData(".word ", 0b0000_1000_0000_0000_0000_0000_1000_0000)] // test that we can use anchors to get pointer locations [InlineData("ldr r0, [pc, ]", 0b01001_000_11011111)] // -33*4+4=-128 [InlineData("ldrb r1, [r1, r2]", 0b0101110_010_001_001)] + [InlineData("ldrh r2, [r1, #0]", 0b10001_00000_001010)] public void ThumbCompilerTests(string input, uint output) { var bytes = new List { (byte)output, (byte)(output >> 8) }; var model = new PokemonModel(new byte[0x200]);