minor bugfixes

xor as an alias for eor
r1 >>= 2 should compile correctly
fix crash when writing thumb code
This commit is contained in:
haven1433 2023-12-01 10:43:01 -06:00
parent 8e81968a50
commit fab59ae727
3 changed files with 10 additions and 2 deletions

View File

@ -970,8 +970,9 @@ namespace HavenSoft.HexManiac.Core.Models.Code {
list = 0;
while (line.Length > 0 && template.Length > 0) {
// make sure that the basic format matches where it should
while (template[0] == ' ' || template[0] == ',') template = template.Substring(1);
while (line[0] == ' ' || line[0] == '!' || line[0] == ',') line = line.Substring(1);
while (template.Length > 0 && (template[0] == ' ' || template[0] == ',')) template = template.Substring(1);
while (line.Length > 0 && (line[0] == ' ' || line[0] == '!' || line[0] == ',')) line = line.Substring(1);
if (template.Length == 0 || line.Length == 0) continue;
if (template[0] == '[') {
if (line[0] != '[') {
if (template.StartsWith("[pc, ") && template.EndsWith("]") && labels.ResolveLabel(line) != Pointer.NULL) {

View File

@ -38,6 +38,7 @@ nv=1111 @ never
00000 # rm rd | lsl rd, rm, # @ rd = rm << #
00000 # rd rd | lsl rd, # @ rd <<= #
00001 # rm rd | lsr rd, rm, # @ rd = rm >> #
00001 # rd rd | lsr rd, # @ rd >>= #
00010 # rm rd | asr rd, rm, # @ rd = rm >>> #
0001100 rm rn rd | add rd, rn, rm @ rd = rn + rm
0001101 rm rn rd | sub rd, rn, rm @ rd = rn - rm
@ -55,6 +56,9 @@ nv=1111 @ never
0100000001 rm rd | eor rd, rm @ rd ^= rm
0100000001 rm rd | eor rd, rd, rm @ rd ^= rm
0100000001 rm rd | eor rd, rm, rd @ rd ^= rm
0100000001 rm rd | xor rd, rm @ rd ^= rm
0100000001 rm rd | xor rd, rd, rm @ rd ^= rm
0100000001 rm rd | xor rd, rm, rd @ rd ^= rm
0100000010 rs rd | lsl rd, rs @ rd <<= rs
0100000011 rs rd | lsr rd, rs @ rd >>= rs
0100000100 rs rd | asr rd, rs @ rd >>>= rs

View File

@ -597,10 +597,13 @@ namespace HavenSoft.HexManiac.Tests {
[InlineData("r1 = 100() + 3", "bl <100>; mov r1, r0; add r1, #3")]
[InlineData("r1 |= r2", "orr r1, r2")]
[InlineData("r1 ^= r2", "xor r1, r2")]
[InlineData("r1 ^= r2", "eor r1, r2")]
[InlineData("r1 &= r2", "and r1, r2")]
[InlineData("r1 *= r2", "mul r1, r2")]
[InlineData("r1 <<= r2", "lsl r1, r2")]
[InlineData("r1 >>= r2", "lsr r1, r2")]
[InlineData("r1 >>= 2", "lsr r1, #2")]
[InlineData("lsr r1, #2", "lsr r1, r1, #2")]
public void ThumbCode_Math_Compiles(string math, string code) {
var model = new PokemonModel(new byte[0x200]);
var result = parser.Compile(model, 0x100, math);