Implement Thumb Instructions: STRH (imm), LDRH (imm)
This commit is contained in:
parent
f9755870bb
commit
a605a43ef9
3 changed files with 30 additions and 2 deletions
|
@ -108,8 +108,8 @@ boost::optional<const Thumb16Matcher<V>&> DecodeThumb16(u16 instruction) {
|
||||||
INST(&V::thumb16_LDRB_reg, "LDRB (reg)", "0101110mmmnnnttt"),
|
INST(&V::thumb16_LDRB_reg, "LDRB (reg)", "0101110mmmnnnttt"),
|
||||||
INST(&V::thumb16_LDRSH_reg, "LDRSH (reg)", "0101111mmmnnnttt"),
|
INST(&V::thumb16_LDRSH_reg, "LDRSH (reg)", "0101111mmmnnnttt"),
|
||||||
INST(&V::thumb16_LDR_imm_t1, "LDR (imm, T1)", "01101vvvvvnnnttt"),
|
INST(&V::thumb16_LDR_imm_t1, "LDR (imm, T1)", "01101vvvvvnnnttt"),
|
||||||
//INST(&V::thumb16_STRH_imm, "STRH (imm)", "10000vvvvvnnnttt"),
|
INST(&V::thumb16_STRH_imm, "STRH (imm)", "10000vvvvvnnnttt"),
|
||||||
//INST(&V::thumb16_LDRH_imm, "LDRH (imm)", "10001vvvvvnnnttt"),
|
INST(&V::thumb16_LDRH_imm, "LDRH (imm)", "10001vvvvvnnnttt"),
|
||||||
//INST(&V::thumb16_STR_sp, "STR (SP)", "10010dddvvvvvvvv"),
|
//INST(&V::thumb16_STR_sp, "STR (SP)", "10010dddvvvvvvvv"),
|
||||||
//INST(&V::thumb16_LDR_sp, "LDR (SP)", "10011dddvvvvvvvv"),
|
//INST(&V::thumb16_LDR_sp, "LDR (SP)", "10011dddvvvvvvvv"),
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,16 @@ public:
|
||||||
return Common::StringFromFormat("ldr %s, [%s, #%u]", RegStr(t), RegStr(n), imm32);
|
return Common::StringFromFormat("ldr %s, [%s, #%u]", RegStr(t), RegStr(n), imm32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string thumb16_STRH_imm(Imm5 imm5, Reg n, Reg t) {
|
||||||
|
u32 imm32 = imm5 << 1;
|
||||||
|
return Common::StringFromFormat("strh %s, [%s, #%u]", RegStr(t), RegStr(n), imm32);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string thumb16_LDRH_imm(Imm5 imm5, Reg n, Reg t) {
|
||||||
|
u32 imm32 = imm5 << 1;
|
||||||
|
return Common::StringFromFormat("ldrh %s, [%s, #%u]", RegStr(t), RegStr(n), imm32);
|
||||||
|
}
|
||||||
|
|
||||||
std::string thumb16_ADR(Reg d, Imm8 imm8) {
|
std::string thumb16_ADR(Reg d, Imm8 imm8) {
|
||||||
u32 imm32 = imm8 << 2;
|
u32 imm32 = imm8 << 2;
|
||||||
return Common::StringFromFormat("adr %s, +#%u", RegStr(d), imm32);
|
return Common::StringFromFormat("adr %s, +#%u", RegStr(d), imm32);
|
||||||
|
|
|
@ -486,6 +486,24 @@ struct ThumbTranslatorVisitor final {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool thumb16_STRH_imm(Imm5 imm5, Reg n, Reg t) {
|
||||||
|
u32 imm32 = imm5 << 1;
|
||||||
|
// STRH <Rt>, [<Rn>, #<imm5>]
|
||||||
|
auto address = ir.Add(ir.GetRegister(n), ir.Imm32(imm32));
|
||||||
|
auto data = ir.LeastSignificantHalf(ir.GetRegister(t));
|
||||||
|
ir.WriteMemory16(address, data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool thumb16_LDRH_imm(Imm5 imm5, Reg n, Reg t) {
|
||||||
|
u32 imm32 = imm5 << 1;
|
||||||
|
// LDRH <Rt>, [<Rn>, #<imm5>]
|
||||||
|
auto address = ir.Add(ir.GetRegister(n), ir.Imm32(imm32));
|
||||||
|
auto data = ir.ZeroExtendHalfToWord(ir.ReadMemory16(address));
|
||||||
|
ir.SetRegister(t, data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool thumb16_ADR(Reg d, Imm8 imm8) {
|
bool thumb16_ADR(Reg d, Imm8 imm8) {
|
||||||
u32 imm32 = imm8 << 2;
|
u32 imm32 = imm8 << 2;
|
||||||
// ADR <Rd>, <label>
|
// ADR <Rd>, <label>
|
||||||
|
|
Loading…
Reference in a new issue