diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 461a3f20..eb545434 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -110,8 +110,7 @@ INST(thumb32_BXJ, "BXJ", "111100111100mmmm100011 //INST(thumb32_SUBS_pc_lr, "SUBS PC, LR", "111100111101111010001111--------") //INST(thumb32_MRS_banked, "MRS (banked)", "11110011111-----10-0------1-----") -//INST(thumb32_MRS_reg_1, "MRS (reg)", "111100111111----10-0------0-----") -//INST(thumb32_MRS_reg_2, "MRS (reg)", "111100111110----10-0------0-----") +INST(thumb32_MRS_reg, "MRS (reg)", "11110011111R11111000dddd00000000") //INST(thumb32_HVC, "HVC", "111101111110----1000------------") //INST(thumb32_SMC, "SMC", "111101111111----1000000000000000") INST(thumb32_UDF, "UDF", "111101111111----1010------------") // v6T2 diff --git a/src/frontend/A32/translate/impl/thumb32_control.cpp b/src/frontend/A32/translate/impl/thumb32_control.cpp index 61b2f713..253e6e62 100644 --- a/src/frontend/A32/translate/impl/thumb32_control.cpp +++ b/src/frontend/A32/translate/impl/thumb32_control.cpp @@ -66,4 +66,19 @@ bool TranslatorVisitor::thumb32_YIELD() { return thumb16_YIELD(); } +bool TranslatorVisitor::thumb32_MRS_reg(bool read_spsr, Reg d) { + if (d == Reg::R15) { + return UnpredictableInstruction(); + } + + // TODO: Revisit when implementing more than user mode. + + if (read_spsr) { + return UndefinedInstruction(); + } + + ir.SetRegister(d, ir.GetCpsr()); + return true; +} + } // namespace Dynarmic::A32 diff --git a/src/frontend/A32/translate/impl/translate.h b/src/frontend/A32/translate/impl/translate.h index f0fa4a0f..c6f82a4d 100644 --- a/src/frontend/A32/translate/impl/translate.h +++ b/src/frontend/A32/translate/impl/translate.h @@ -575,6 +575,7 @@ struct TranslatorVisitor final { bool thumb32_WFE(); bool thumb32_WFI(); bool thumb32_YIELD(); + bool thumb32_MSR_reg(bool R, Reg n, Imm<4> mask); // thumb32 branch instructions bool thumb32_BL_imm(Imm<1> S, Imm<10> hi, Imm<1> j1, Imm<1> j2, Imm<11> lo); diff --git a/tests/A32/fuzz_arm.cpp b/tests/A32/fuzz_arm.cpp index 1e90799b..8acac3f8 100644 --- a/tests/A32/fuzz_arm.cpp +++ b/tests/A32/fuzz_arm.cpp @@ -192,6 +192,9 @@ std::vector GenRandomThumbInst(u32 pc, bool is_last_inst, A32::ITState it_s // FPSCR is inaccurate "vfp_VMRS", + // Unicorn is incorrect? + "thumb32_MRS_reg", + // Unicorn has incorrect implementation (incorrect rounding and unsets CPSR.T??) "vfp_VCVT_to_fixed", "vfp_VCVT_from_fixed",