ldrh should compile correctly

This commit is contained in:
Benjamin Popp 2019-07-27 22:06:32 -05:00
parent ab1ace2535
commit dbe054d090
2 changed files with 2 additions and 1 deletions

View File

@ -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;

View File

@ -390,6 +390,7 @@ namespace HavenSoft.HexManiac.Tests {
[InlineData(".word <bob>", 0b0000_1000_0000_0000_0000_0000_1000_0000)] // test that we can use anchors to get pointer locations
[InlineData("ldr r0, [pc, <bob>]", 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> { (byte)output, (byte)(output >> 8) };
var model = new PokemonModel(new byte[0x200]);