From 691e4139fa920d4ce103e13f63af5a480faf7e5c Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 2 Aug 2016 19:52:17 -0400 Subject: [PATCH] arm: Implement B/BL/BX instructions. --- src/CMakeLists.txt | 1 + src/frontend/decoder/arm.h | 6 +- .../translate/translate_arm/branch.cpp | 65 +++++++++++++++++++ .../translate/translate_arm/translate_arm.h | 8 +++ 4 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 src/frontend/translate/translate_arm/branch.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f160e42..31331121 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,7 @@ set(SRCS frontend/ir/ir_emitter.cpp frontend/translate/translate.cpp frontend/translate/translate_arm.cpp + frontend/translate/translate_arm/branch.cpp frontend/translate/translate_arm/data_processing.cpp frontend/translate/translate_arm/exception_generating.cpp frontend/translate/translate_arm/extension.cpp diff --git a/src/frontend/decoder/arm.h b/src/frontend/decoder/arm.h index e8bbe5d8..0367b8d8 100644 --- a/src/frontend/decoder/arm.h +++ b/src/frontend/decoder/arm.h @@ -66,9 +66,9 @@ boost::optional&> DecodeArm(u32 instruction) { // Branch instructions //INST(&V::arm_BLX_imm, "BLX (imm)", "1111101hvvvvvvvvvvvvvvvvvvvvvvvv"), // v5 //INST(&V::arm_BLX_reg, "BLX (reg)", "cccc000100101111111111110011mmmm"), // v5 - //INST(&V::arm_B, "B", "cccc1010vvvvvvvvvvvvvvvvvvvvvvvv"), // all - //INST(&V::arm_BL, "BL", "cccc1011vvvvvvvvvvvvvvvvvvvvvvvv"), // all - //INST(&V::arm_BX, "BX", "cccc000100101111111111110001mmmm"), // v4T + INST(&V::arm_B, "B", "cccc1010vvvvvvvvvvvvvvvvvvvvvvvv"), // all + INST(&V::arm_BL, "BL", "cccc1011vvvvvvvvvvvvvvvvvvvvvvvv"), // all + INST(&V::arm_BX, "BX", "cccc000100101111111111110001mmmm"), // v4T //INST(&V::arm_BXJ, "BXJ", "cccc000100101111111111110010mmmm"), // v5J // Coprocessor instructions diff --git a/src/frontend/translate/translate_arm/branch.cpp b/src/frontend/translate/translate_arm/branch.cpp new file mode 100644 index 00000000..c2703d71 --- /dev/null +++ b/src/frontend/translate/translate_arm/branch.cpp @@ -0,0 +1,65 @@ +/* This file is part of the dynarmic project. + * Copyright (c) 2016 MerryMage + * This software may be used and distributed according to the terms of the GNU + * General Public License version 2 or any later version. + */ + +#include "common/bit_util.h" + +#include "translate_arm.h" + +namespace Dynarmic { +namespace Arm { + +bool ArmTranslatorVisitor::arm_B(Cond cond, Imm24 imm24) +{ + s32 imm32 = Common::SignExtend<26, s32>(imm24 << 2) + 8; + // B