thumb tool should allow +1's on words

This commit is contained in:
haven1433
2022-11-02 08:43:08 -05:00
parent 614244dd88
commit 2428ba8231
2 changed files with 13 additions and 0 deletions

View File

@@ -999,7 +999,14 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
// Parse successful! Nothing else to do.
} else {
if (line.StartsWith("0x")) line = line.Substring(2);
var add = 0;
if (line.Contains("+")) {
var parts = line.Split("+");
if (!int.TryParse(parts[1], out add)) return false;
line = parts[0];
}
if (!int.TryParse(line, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out result)) return false;
result += add;
}
results = new[] {
(byte)result,

View File

@@ -175,5 +175,11 @@ namespace HavenSoft.HexManiac.Tests {
ThumbScript = "add r3,r3,#6; add r3, #6";
Assert.Equal(Model.ReadMultiByteValue(0, 2), Model.ReadMultiByteValue(2, 2));
}
[Fact]
public void Word_PlusOne_Compiles() {
ThumbScript = ".word 0x8123456+1";
Assert.Equal(0x57, Model[0]);
}
}
}