mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-10-02 13:16:35 -05:00
add alias instruction so that add rX, rX, #Y maps to add rX, #Y
This commit is contained in:
@@ -782,6 +782,7 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
|
||||
for (int index = 0; index < instructionParts.Count; index++) {
|
||||
var instruction = instructionParts[index];
|
||||
if (instruction.Name != name) continue;
|
||||
if (registerValues.ContainsKey(index) && registerValues[index] != value) return false;
|
||||
registerValues[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ nv=1111 @ never
|
||||
0001100 rm rn rd | add rd, rn, rm @ rd = rn + rm
|
||||
0001101 rm rn rd | sub rd, rn, rm @ rd = rn - rm
|
||||
0001110000 rn rd | mov rd, rn @ rd = rn
|
||||
00110 rd # | add rd, rd, # @ rd += # (alais)
|
||||
0001110 # rn rd | add rd, rn, # @ rd = rn + #
|
||||
0001111 # rn rd | sub rd, rn, # @ rd = rn - #
|
||||
00100 rd # | mov rd, # @ rd = #
|
||||
|
||||
@@ -375,6 +375,8 @@ namespace HavenSoft.HexManiac.Tests {
|
||||
[InlineData("add r0, r1, r2", 0b0001100_010_001_000)]
|
||||
[InlineData("add r0, r1", 0b0001100_001_000_000)]
|
||||
[InlineData("add r8, r0", 0b1000100_1_0_000_000)]
|
||||
[InlineData("add r0, r1, #4", 0b0001110_100_001_000)]
|
||||
[InlineData("add r2, r2, #4", 0b00110_010_00000100)]
|
||||
[InlineData("lsl r1, r2, #4", 0b00000_00100_010_001)]
|
||||
[InlineData("lsl r1, #4", 0b00000_00100_001_001)]
|
||||
[InlineData("bls <000120>", 0b1101_1001_00001110)]
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace HavenSoft.HexManiac.Tests {
|
||||
get => ";".Join(Tool.Contents[0].Content.SplitLines().Select(line => line.Trim()));
|
||||
set => Tool.Contents[0].Content = value.Replace(";", Environment.NewLine);
|
||||
}
|
||||
private string ThumbScript {
|
||||
set => Tool.Content = value.Replace(";", Environment.NewLine);
|
||||
}
|
||||
private string GetContent(int index) => Tool.Contents[index].Content;
|
||||
private void SetContent(int index, string content) => Tool.Contents[index].Content = content.Replace(";", Environment.NewLine);
|
||||
|
||||
@@ -166,5 +169,11 @@ namespace HavenSoft.HexManiac.Tests {
|
||||
Assert.IsType<PointerRun>(Model.GetNextRun(5));
|
||||
Model.ResolveConflicts();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddWithTwoSameRegisters_AddWithOneRegister_SameCode() {
|
||||
ThumbScript = "add r3,r3,#6; add r3, #6";
|
||||
Assert.Equal(Model.ReadMultiByteValue(0, 2), Model.ReadMultiByteValue(2, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user