thumb32: Implement STRB/STRH/STR (register)
This commit is contained in:
parent
ac32175eff
commit
5601aa554e
4 changed files with 59 additions and 3 deletions
|
@ -162,6 +162,7 @@ if ("A32" IN_LIST DYNARMIC_FRONTENDS)
|
|||
frontend/A32/translate/impl/thumb32_misc.cpp
|
||||
frontend/A32/translate/impl/thumb32_multiply.cpp
|
||||
frontend/A32/translate/impl/thumb32_parallel.cpp
|
||||
frontend/A32/translate/impl/thumb32_store_single_data_item.cpp
|
||||
frontend/A32/translate/impl/translate_arm.h
|
||||
frontend/A32/translate/impl/translate_thumb.h
|
||||
frontend/A32/translate/impl/vfp.cpp
|
||||
|
|
|
@ -133,17 +133,17 @@ INST(thumb32_BLX_imm, "BLX (imm)", "11110Svvvvvvvvvv11j0jv
|
|||
//INST(thumb32_STRB_imm_2, "STRB (imm)", "111110000000--------1100--------")
|
||||
//INST(thumb32_STRB_imm_3, "STRB (imm)", "111110001000--------------------")
|
||||
//INST(thumb32_STRBT, "STRBT", "111110000000--------1110--------")
|
||||
//INST(thumb32_STRB, "STRB (reg)", "111110000000--------000000------")
|
||||
INST(thumb32_STRB, "STRB (reg)", "111110000000nnnntttt000000iimmmm")
|
||||
//INST(thumb32_STRH_imm_1, "STRH (imm)", "111110000010--------1--1--------")
|
||||
//INST(thumb32_STRH_imm_2, "STRH (imm)", "111110000010--------1100--------")
|
||||
//INST(thumb32_STRH_imm_3, "STRH (imm)", "111110001010--------------------")
|
||||
//INST(thumb32_STRHT, "STRHT", "111110000010--------1110--------")
|
||||
//INST(thumb32_STRH, "STRH (reg)", "111110000010--------000000------")
|
||||
INST(thumb32_STRH, "STRH (reg)", "111110000010nnnntttt000000iimmmm")
|
||||
//INST(thumb32_STR_imm_1, "STR (imm)", "111110000100--------1--1--------")
|
||||
//INST(thumb32_STR_imm_2, "STR (imm)", "111110000100--------1100--------")
|
||||
//INST(thumb32_STR_imm_3, "STR (imm)", "111110001100--------------------")
|
||||
//INST(thumb32_STRT, "STRT", "111110000100--------1110--------")
|
||||
//INST(thumb32_STR_reg, "STR (reg)", "111110000100--------000000------")
|
||||
INST(thumb32_STR_reg, "STR (reg)", "111110000100nnnntttt000000iimmmm")
|
||||
|
||||
// Load Byte and Memory Hints
|
||||
//INST(thumb32_PLD_lit, "PLD (lit)", "11111000-00111111111------------")
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2021 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#include "frontend/A32/translate/impl/translate_thumb.h"
|
||||
|
||||
namespace Dynarmic::A32 {
|
||||
|
||||
template <typename StoreRegFn>
|
||||
static bool StoreRegister(ThumbTranslatorVisitor& v, Reg n, Reg t, Imm<2> imm2, Reg m, StoreRegFn store_fn) {
|
||||
if (n == Reg::PC) {
|
||||
return v.UndefinedInstruction();
|
||||
}
|
||||
|
||||
if (t == Reg::PC || m == Reg::PC) {
|
||||
return v.UnpredictableInstruction();
|
||||
}
|
||||
|
||||
const auto reg_m = v.ir.GetRegister(m);
|
||||
const auto reg_n = v.ir.GetRegister(n);
|
||||
const auto reg_t = v.ir.GetRegister(t);
|
||||
|
||||
const auto shift_amount = v.ir.Imm8(static_cast<u8>(imm2.ZeroExtend()));
|
||||
const auto offset = v.ir.LogicalShiftLeft(reg_m, shift_amount);
|
||||
const auto offset_address = v.ir.Add(reg_n, offset);
|
||||
|
||||
store_fn(offset_address, reg_t);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ThumbTranslatorVisitor::thumb32_STRB(Reg n, Reg t, Imm<2> imm2, Reg m) {
|
||||
return StoreRegister(*this, n, t, imm2, m, [this](const IR::U32& offset_address, const IR::U32& data) {
|
||||
ir.WriteMemory8(offset_address, ir.LeastSignificantByte(data));
|
||||
});
|
||||
}
|
||||
|
||||
bool ThumbTranslatorVisitor::thumb32_STRH(Reg n, Reg t, Imm<2> imm2, Reg m) {
|
||||
return StoreRegister(*this, n, t, imm2, m, [this](const IR::U32& offset_address, const IR::U32& data) {
|
||||
ir.WriteMemory16(offset_address, ir.LeastSignificantHalf(data));
|
||||
});
|
||||
}
|
||||
|
||||
bool ThumbTranslatorVisitor::thumb32_STR_reg(Reg n, Reg t, Imm<2> imm2, Reg m) {
|
||||
return StoreRegister(*this, n, t, imm2, m, [this](const IR::U32& offset_address, const IR::U32& data) {
|
||||
ir.WriteMemory32(offset_address, data);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::A32
|
|
@ -181,6 +181,11 @@ struct ThumbTranslatorVisitor final {
|
|||
bool thumb32_BL_imm(Imm<1> S, Imm<10> hi, Imm<1> j1, Imm<1> j2, Imm<11> lo);
|
||||
bool thumb32_BLX_imm(Imm<1> S, Imm<10> hi, Imm<1> j1, Imm<1> j2, Imm<11> lo);
|
||||
|
||||
// thumb32 store single data item instructions
|
||||
bool thumb32_STRB(Reg n, Reg t, Imm<2> imm2, Reg m);
|
||||
bool thumb32_STRH(Reg n, Reg t, Imm<2> imm2, Reg m);
|
||||
bool thumb32_STR_reg(Reg n, Reg t, Imm<2> imm2, Reg m);
|
||||
|
||||
// thumb32 data processing (register) instructions
|
||||
bool thumb32_SXTB(Reg d, SignExtendRotation rotate, Reg m);
|
||||
bool thumb32_SXTB16(Reg d, SignExtendRotation rotate, Reg m);
|
||||
|
|
Loading…
Reference in a new issue