diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 4c8c43cdf2..0b8410e2f4 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -96,9 +96,9 @@ size_t fmt::detail::get_fmt_len(const char* fmt, size_t len) fmt += 2; len -= 2; - if (fmt[1] == '1') + if (fmt[0] == '1') { - assert(len >= 3 && fmt[2] - '0' < 7); + assert(len >= 3 && fmt[1] - '0' < 7); res++; fmt++; len--; diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 36a1ee4abb..557a51ec4a 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -198,7 +198,7 @@ namespace fmt { return to_hex(arg, get_fmt_precision(fmt, len)); } - else if (fmt[len - 1] == 'd') + else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u') { return to_udec(arg); } @@ -220,7 +220,7 @@ namespace fmt { return to_hex(arg, get_fmt_precision(fmt, len)); } - else if (fmt[len - 1] == 'd') + else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u') { return to_udec(arg); } @@ -242,7 +242,7 @@ namespace fmt { return to_hex(arg, get_fmt_precision(fmt, len)); } - else if (fmt[len - 1] == 'd') + else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u') { return to_udec(arg); } @@ -264,7 +264,7 @@ namespace fmt { return to_hex(arg, get_fmt_precision(fmt, len)); } - else if (fmt[len - 1] == 'd') + else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u') { return to_udec(arg); } @@ -418,7 +418,7 @@ namespace fmt { return to_hex(arg, get_fmt_precision(fmt, len)); } - else if (fmt[len - 1] == 'd') + else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u') { return arg ? "1" : "0"; } @@ -435,24 +435,6 @@ namespace fmt } }; - template<> - struct get_fmt - { - static std::string text(const char* fmt, size_t len, char* arg) - { - if (fmt[len - 1] == 's') - { - return arg; - } - else - { - throw "Invalid formatting (char*): " + std::string(fmt, len); - } - - return{}; - } - }; - template<> struct get_fmt { @@ -471,60 +453,6 @@ namespace fmt } }; - //template - //struct get_fmt - //{ - // static std::string text(const char* fmt, size_t len, const char(&arg)[size]) - // { - // if (fmt[len - 1] == 's') - // { - // return std::string(arg, size); - // } - // else - // { - // throw "Invalid formatting (char[size]): " + std::string(fmt, len); - // } - - // return{}; - // } - //}; - - //template - //struct get_fmt - //{ - // static std::string text(const char* fmt, size_t len, const char(&arg)[size]) - // { - // if (fmt[len - 1] == 's') - // { - // return std::string(arg, size); - // } - // else - // { - // throw "Invalid formatting (const char[size]): " + std::string(fmt, len); - // } - - // return{}; - // } - //}; - - template<> - struct get_fmt - { - static std::string text(const char* fmt, size_t len, const std::string& arg) - { - if (fmt[len - 1] == 's') - { - return arg; - } - else - { - throw "Invalid formatting (std::string): " + std::string(fmt, len); - } - - return{}; - } - }; - std::string format(const char* fmt, size_t len); // terminator template @@ -549,6 +477,17 @@ namespace fmt } }; + template<> + struct unveil + { + typedef const char* result_type; + + __forceinline static result_type get_value(const char* arg) + { + return arg; + } + }; + template struct unveil { @@ -563,11 +502,11 @@ namespace fmt template<> struct unveil { - typedef const std::string& result_type; + typedef const char* result_type; __forceinline static result_type get_value(const std::string& arg) { - return arg; + return arg.c_str(); } }; @@ -613,8 +552,9 @@ namespace fmt float (%x, %f) double (%x, %f) bool (%x, %d, %s) - char*, const char*, std::string (%s) + char* (%s) + std::string forced to .c_str() (fmt::unveil) be_t<> of any appropriate type in this list (fmt::unveil) enum of any appropriate type in this list (fmt::unveil) diff --git a/rpcs3/Emu/ARMv7/ARMv7Callback.h b/rpcs3/Emu/ARMv7/ARMv7Callback.h new file mode 100644 index 0000000000..4f9c72d1e0 --- /dev/null +++ b/rpcs3/Emu/ARMv7/ARMv7Callback.h @@ -0,0 +1,18 @@ +#pragma once +#include "Emu/Memory/Memory.h" +#include "Emu/ARMv7/PSVFuncList.h" + +namespace vm +{ + template + __forceinline RT _ptr_base::operator()(ARMv7Context& context, T... args) const + { + return psv_func_detail::func_caller::call(context, vm::cast(this->addr()), args...); + } +} + +template +__forceinline RT cb_call(ARMv7Context& context, u32 addr, T... args) +{ + return psv_func_detail::func_caller::call(context, addr, args...); +} \ No newline at end of file diff --git a/rpcs3/Emu/ARMv7/ARMv7Context.h b/rpcs3/Emu/ARMv7/ARMv7Context.h new file mode 100644 index 0000000000..be06cc4a45 --- /dev/null +++ b/rpcs3/Emu/ARMv7/ARMv7Context.h @@ -0,0 +1,276 @@ +#pragma once + +class ARMv7Thread; + +enum ARMv7InstructionSet +{ + ARM, + Thumb, + Jazelle, + ThumbEE +}; + +struct ARMv7Context +{ + ARMv7Thread& thread; + + ARMv7Context(ARMv7Thread& thread) : thread(thread) {} + + void write_pc(u32 value); + u32 read_pc(); + void put_stack_arg(u32 shift, u32 value); + u32 get_stack_arg(u32 pos); + void fast_call(u32 addr); + + union + { + u32 GPR[15]; + + struct + { + u32 pad[13]; + + union + { + u32 SP; + + struct { u16 SP_main, SP_process; }; + }; + + u32 LR; + }; + }; + + union + { + struct + { + u32 N : 1; //Negative condition code flag + u32 Z : 1; //Zero condition code flag + u32 C : 1; //Carry condition code flag + u32 V : 1; //Overflow condition code flag + u32 Q : 1; //Set to 1 if an SSAT or USAT instruction changes (saturates) the input value for the signed or unsigned range of the result + u32 dummy : 27; + }; + + u32 APSR; + + } APSR; + + union + { + struct + { + u32 dummy : 24; + u32 exception : 8; + }; + + u32 IPSR; + + } IPSR; + + ARMv7InstructionSet ISET; + + union + { + struct + { + u8 cond : 3; + u8 state : 5; + }; + + u8 IT; + + u32 advance() + { + const u32 res = (state & 0xf) ? (cond << 1 | state >> 4) : 0xe /* true */; + + state <<= 1; + if ((state & 0xf) == 0) // if no d + { + IT = 0; // clear ITSTATE + } + + return res; + } + + operator bool() const + { + return (state & 0xf) != 0; + } + + } ITSTATE; + + u32 R_ADDR; + u64 R_DATA; + + void write_gpr(u32 n, u32 value) + { + assert(n < 16); + + if (n < 15) + { + GPR[n] = value; + } + else + { + write_pc(value & ~1); + } + } + + u32 read_gpr(u32 n) + { + assert(n < 16); + + if (n < 15) + { + return GPR[n]; + } + + return read_pc(); + } + + // function for processing va_args in printf-like functions + u32 get_next_gpr_arg(u32& g_count, u32& f_count, u32& v_count) + { + assert(!f_count && !v_count); // not supported + + if (g_count < 4) + { + return GPR[g_count++]; + } + else + { + return get_stack_arg(g_count++); + } + } +}; + +template::value> +struct cast_armv7_gpr +{ + static_assert(is_enum, "Invalid type for cast_armv7_gpr"); + + typedef typename std::underlying_type::type underlying_type; + + __forceinline static u32 to_gpr(const T& value) + { + return cast_armv7_gpr::to_gpr(static_cast(value)); + } + + __forceinline static T from_gpr(const u32 reg) + { + return static_cast(cast_armv7_gpr::from_gpr(reg)); + } +}; + +template<> +struct cast_armv7_gpr +{ + __forceinline static u32 to_gpr(const u8& value) + { + return value; + } + + __forceinline static u8 from_gpr(const u32 reg) + { + return static_cast(reg); + } +}; + +template<> +struct cast_armv7_gpr +{ + __forceinline static u32 to_gpr(const u16& value) + { + return value; + } + + __forceinline static u16 from_gpr(const u32 reg) + { + return static_cast(reg); + } +}; + +template<> +struct cast_armv7_gpr +{ + __forceinline static u32 to_gpr(const u32& value) + { + return value; + } + + __forceinline static u32 from_gpr(const u32 reg) + { + return reg; + } +}; + +template<> +struct cast_armv7_gpr +{ + __forceinline static u32 to_gpr(const s8& value) + { + return value; + } + + __forceinline static s8 from_gpr(const u32 reg) + { + return static_cast(reg); + } +}; + +template<> +struct cast_armv7_gpr +{ + __forceinline static u32 to_gpr(const s16& value) + { + return value; + } + + __forceinline static s16 from_gpr(const u32 reg) + { + return static_cast(reg); + } +}; + +template<> +struct cast_armv7_gpr +{ + __forceinline static u32 to_gpr(const s32& value) + { + return value; + } + + __forceinline static s32 from_gpr(const u32 reg) + { + return static_cast(reg); + } +}; + +template<> +struct cast_armv7_gpr +{ + __forceinline static u32 to_gpr(const bool& value) + { + return value; + } + + __forceinline static bool from_gpr(const u32 reg) + { + return reinterpret_cast(reg); + } +}; + +template +__forceinline u32 cast_to_armv7_gpr(const T& value) +{ + return cast_armv7_gpr::to_gpr(value); +} + +template +__forceinline T cast_from_armv7_gpr(const u32 reg) +{ + return cast_armv7_gpr::from_gpr(reg); +} + diff --git a/rpcs3/Emu/ARMv7/ARMv7Decoder.cpp b/rpcs3/Emu/ARMv7/ARMv7Decoder.cpp new file mode 100644 index 0000000000..42bda91fd6 --- /dev/null +++ b/rpcs3/Emu/ARMv7/ARMv7Decoder.cpp @@ -0,0 +1,1305 @@ +#include "stdafx.h" +#include +#include "Utilities/Log.h" +#include "ARMv7Thread.h" +#include "ARMv7Interpreter.h" +#include "ARMv7Opcodes.h" +#include "ARMv7Decoder.h" + +struct ARMv7_opcode_t +{ + u32 mask; + u32 code; + u32 length; // 2 or 4 + const char* name; + ARMv7_encoding type; + void(*func)(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + bool(*skip)(u32 code); +}; + +// single 16-bit value +#define ARMv7_OP2(mask, code, type, name, ...) { (u32)((mask) << 16), (u32)((code) << 16), 2, #name "_" #type, type, ARMv7_instrs::name, __VA_ARGS__ } +// two 16-bit values +#define ARMv7_OP4(mask0, mask1, code0, code1, type, name, ...) { (u32)((mask0) << 16) | (mask1), (u32)((code0) << 16) | (code1), 4, #name "_" #type, type, ARMv7_instrs::name, __VA_ARGS__ } + +#define SKIP_IF(cond) [](u32 c) -> bool { return cond; } + +#define BF(start, end) ((c << (31 - (end))) >> ((start) + 31 - (end))) +#define BT(pos) ((c >> (pos)) & 1) + +const ARMv7_opcode_t ARMv7_opcode_table[] = +{ + ARMv7_OP2(0xffff, 0x0000, T1, NULL_OP), // ??? + + ARMv7_OP4(0xffff, 0x0000, 0xf870, 0x0000, T1, HACK), // "Undefined" Thumb opcode used + ARMv7_OP4(0x0ff0, 0x00f0, 0x0070, 0x0090, A1, HACK), // "Undefined" ARM opcode used + + ARMv7_OP4(0xfbe0, 0x8000, 0xf140, 0x0000, T1, ADC_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x02a0, 0x0000, A1, ADC_IMM), + ARMv7_OP2(0xffc0, 0x4040, T1, ADC_REG), + ARMv7_OP4(0xffe0, 0x8000, 0xeb40, 0x0000, T2, ADC_REG), + ARMv7_OP4(0x0fe0, 0x0010, 0x00a0, 0x0000, A1, ADC_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x00a0, 0x0010, A1, ADC_RSR), + + ARMv7_OP2(0xfe00, 0x1c00, T1, ADD_IMM), + ARMv7_OP2(0xf800, 0x3000, T2, ADD_IMM), + ARMv7_OP4(0xfbe0, 0x8000, 0xf100, 0x0000, T3, ADD_IMM, SKIP_IF( (BF(8, 11) == 15 && BT(20)) || BF(16, 19) == 13 )), + ARMv7_OP4(0xfbf0, 0x8000, 0xf200, 0x0000, T4, ADD_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x0280, 0x0000, A1, ADD_IMM), + ARMv7_OP2(0xfe00, 0x1800, T1, ADD_REG), + ARMv7_OP2(0xff00, 0x4400, T2, ADD_REG, SKIP_IF( (c & 0x87) == 0x85 || BF(3, 6) == 13 )), + ARMv7_OP4(0xffe0, 0x8000, 0xeb00, 0x0000, T3, ADD_REG), + ARMv7_OP4(0x0fe0, 0x0010, 0x0080, 0x0000, A1, ADD_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x0080, 0x0010, A1, ADD_RSR), + ARMv7_OP2(0xf800, 0xa800, T1, ADD_SPI), + ARMv7_OP2(0xff80, 0xb000, T2, ADD_SPI), + ARMv7_OP4(0xfbef, 0x8000, 0xf10d, 0x0000, T3, ADD_SPI), + ARMv7_OP4(0xfbff, 0x8000, 0xf20d, 0x0000, T4, ADD_SPI), + ARMv7_OP4(0x0fef, 0x0000, 0x028d, 0x0000, A1, ADD_SPI), + ARMv7_OP2(0xff78, 0x4468, T1, ADD_SPR), + ARMv7_OP2(0xff87, 0x4485, T2, ADD_SPR), + ARMv7_OP4(0xffef, 0x8000, 0xeb0d, 0x0000, T3, ADD_SPR), + ARMv7_OP4(0x0fef, 0x0010, 0x008d, 0x0000, A1, ADD_SPR), + + ARMv7_OP2(0xf800, 0xa000, T1, ADR), + ARMv7_OP4(0xfbff, 0x8000, 0xf2af, 0x0000, T2, ADR), + ARMv7_OP4(0xfbff, 0x8000, 0xf20f, 0x0000, T3, ADR), + ARMv7_OP4(0x0fff, 0x0000, 0x028f, 0x0000, A1, ADR), + ARMv7_OP4(0x0fff, 0x0000, 0x024f, 0x0000, A2, ADR), + + ARMv7_OP4(0xfbe0, 0x8000, 0xf000, 0x0000, T1, AND_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x0200, 0x0000, A1, AND_IMM), + ARMv7_OP2(0xffc0, 0x4000, T1, AND_REG), + ARMv7_OP4(0xffe0, 0x8000, 0xea00, 0x0000, T2, AND_REG), + ARMv7_OP4(0x0fe0, 0x0010, 0x0000, 0x0000, A1, AND_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x0000, 0x0010, A1, AND_RSR), + + ARMv7_OP2(0xf800, 0x1000, T1, ASR_IMM), + ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0020, T2, ASR_IMM), + ARMv7_OP4(0x0fef, 0x0070, 0x01a0, 0x0040, A1, ASR_IMM), + ARMv7_OP2(0xffc0, 0x4100, T1, ASR_REG), + ARMv7_OP4(0xffe0, 0xf0f0, 0xfa40, 0xf000, T2, ASR_REG), + ARMv7_OP4(0x0fef, 0x00f0, 0x01a0, 0x0050, A1, ASR_REG), + + ARMv7_OP2(0xf000, 0xd000, T1, B), + ARMv7_OP2(0xf800, 0xe000, T2, B), + ARMv7_OP4(0xf800, 0xd000, 0xf000, 0x8000, T3, B), + ARMv7_OP4(0xf800, 0xd000, 0xf000, 0x9000, T4, B), + ARMv7_OP4(0x0f00, 0x0000, 0x0a00, 0x0000, A1, B), + + ARMv7_OP4(0xffff, 0x8020, 0xf36f, 0x0000, T1, BFC), + ARMv7_OP4(0x0fe0, 0x007f, 0x07c0, 0x001f, A1, BFC), + ARMv7_OP4(0xfff0, 0x8020, 0xf360, 0x0000, T1, BFI), + ARMv7_OP4(0x0fe0, 0x0070, 0x07c0, 0x0010, A1, BFI), + + ARMv7_OP4(0xfbe0, 0x8000, 0xf020, 0x0000, T1, BIC_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x03c0, 0x0000, A1, BIC_IMM), + ARMv7_OP2(0xffc0, 0x4380, T1, BIC_REG), + ARMv7_OP4(0xffe0, 0x8000, 0xea20, 0x0000, T2, BIC_REG), + ARMv7_OP4(0x0fe0, 0x0010, 0x01c0, 0x0000, A1, BIC_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x01c0, 0x0010, A1, BIC_RSR), + + ARMv7_OP2(0xff00, 0xbe00, T1, BKPT), + ARMv7_OP4(0x0ff0, 0x00f0, 0x0120, 0x0070, A1, BKPT), + + ARMv7_OP4(0xf800, 0xd000, 0xf000, 0xd000, T1, BL), + ARMv7_OP4(0x0f00, 0x0000, 0x0b00, 0x0000, A1, BL), + ARMv7_OP2(0xff80, 0x4780, T1, BLX), + ARMv7_OP4(0xf800, 0xc001, 0xf000, 0xc000, T2, BLX), + ARMv7_OP4(0x0fff, 0xfff0, 0x012f, 0xff30, A1, BLX), + ARMv7_OP4(0xfe00, 0x0000, 0xfa00, 0x0000, A2, BLX), + + ARMv7_OP2(0xff87, 0x4700, T1, BX), + ARMv7_OP4(0x0fff, 0xfff0, 0x012f, 0xff10, A1, BX), + + ARMv7_OP2(0xf500, 0xb100, T1, CB_Z), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfab0, 0xf080, T1, CLZ), + ARMv7_OP4(0x0fff, 0x0ff0, 0x016f, 0x0f10, A1, CLZ), + + ARMv7_OP4(0xfbf0, 0x8f00, 0xf110, 0x0f00, T1, CMN_IMM), + ARMv7_OP4(0x0ff0, 0xf000, 0x0370, 0x0000, A1, CMN_IMM), + ARMv7_OP2(0xffc0, 0x42c0, T1, CMN_REG), + ARMv7_OP4(0xfff0, 0x8f00, 0xeb10, 0x0f00, T2, CMN_REG), + ARMv7_OP4(0x0ff0, 0xf010, 0x0170, 0x0000, A1, CMN_REG), + ARMv7_OP4(0x0ff0, 0xf090, 0x0170, 0x0010, A1, CMN_RSR), + + ARMv7_OP2(0xf800, 0x2800, T1, CMP_IMM), + ARMv7_OP4(0xfbf0, 0x8f00, 0xf1b0, 0x0f00, T2, CMP_IMM), + ARMv7_OP4(0x0ff0, 0xf000, 0x0350, 0x0000, A1, CMP_IMM), + ARMv7_OP2(0xffc0, 0x4280, T1, CMP_REG), + ARMv7_OP2(0xff00, 0x4500, T2, CMP_REG), + ARMv7_OP4(0xfff0, 0x8f00, 0xebb0, 0x0f00, T3, CMP_REG), + ARMv7_OP4(0x0ff0, 0xf010, 0x0150, 0x0000, A1, CMP_REG), + ARMv7_OP4(0x0ff0, 0xf090, 0x0150, 0x0010, A1, CMP_RSR), + + ARMv7_OP4(0xfbe0, 0x8000, 0xf080, 0x0000, T1, EOR_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x0220, 0x0000, A1, EOR_IMM), + ARMv7_OP2(0xffc0, 0x4040, T1, EOR_REG), + ARMv7_OP4(0xffe0, 0x8000, 0xea80, 0x0000, T2, EOR_REG), + ARMv7_OP4(0x0fe0, 0x0010, 0x0020, 0x0000, A1, EOR_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x0020, 0x0010, A1, EOR_RSR), + + ARMv7_OP2(0xff00, 0xbf00, T1, IT), + + ARMv7_OP2(0xf800, 0xc800, T1, LDM), + ARMv7_OP4(0xffd0, 0x2000, 0xe890, 0x0000, T2, LDM), + ARMv7_OP4(0x0fd0, 0x0000, 0x0890, 0x0000, A1, LDM), + ARMv7_OP4(0x0fd0, 0x0000, 0x0810, 0x0000, A1, LDMDA), + ARMv7_OP4(0xffd0, 0x2000, 0xe910, 0x0000, T1, LDMDB), + ARMv7_OP4(0x0fd0, 0x0000, 0x0910, 0x0000, A1, LDMDB), + ARMv7_OP4(0x0fd0, 0x0000, 0x0990, 0x0000, A1, LDMIB), + + ARMv7_OP2(0xf800, 0x6800, T1, LDR_IMM), + ARMv7_OP2(0xf800, 0x9800, T2, LDR_IMM), + ARMv7_OP4(0xfff0, 0x0000, 0xf8d0, 0x0000, T3, LDR_IMM), + ARMv7_OP4(0xfff0, 0x0800, 0xf850, 0x0800, T4, LDR_IMM), + ARMv7_OP4(0x0e50, 0x0000, 0x0410, 0x0000, A1, LDR_IMM), + ARMv7_OP2(0xf800, 0x4800, T1, LDR_LIT), + ARMv7_OP4(0xff7f, 0x0000, 0xf85f, 0x0000, T2, LDR_LIT), + ARMv7_OP4(0x0f7f, 0x0000, 0x051f, 0x0000, A1, LDR_LIT), + ARMv7_OP2(0xfe00, 0x5800, T1, LDR_REG), + ARMv7_OP4(0xfff0, 0x0fc0, 0xf850, 0x0000, T2, LDR_REG), + ARMv7_OP4(0x0e50, 0x0010, 0x0610, 0x0000, A1, LDR_REG), + + ARMv7_OP2(0xf800, 0x7800, T1, LDRB_IMM), + ARMv7_OP4(0xfff0, 0x0000, 0xf890, 0x0000, T2, LDRB_IMM), + ARMv7_OP4(0xfff0, 0x0800, 0xf810, 0x0800, T3, LDRB_IMM), + ARMv7_OP4(0x0e50, 0x0000, 0x0450, 0x0000, A1, LDRB_IMM), + ARMv7_OP4(0xff7f, 0x0000, 0xf81f, 0x0000, T1, LDRB_LIT), + ARMv7_OP4(0x0f7f, 0x0000, 0x055f, 0x0000, A1, LDRB_LIT), + ARMv7_OP2(0xfe00, 0x5c00, T1, LDRB_REG), + ARMv7_OP4(0xfff0, 0x0fc0, 0xf810, 0x0000, T2, LDRB_REG), + ARMv7_OP4(0x0e50, 0x0010, 0x0650, 0x0000, A1, LDRB_REG), + + ARMv7_OP4(0xfe50, 0x0000, 0xe850, 0x0000, T1, LDRD_IMM, SKIP_IF( (!BT(21) && !BT(24)) || BF(16, 19) == 15 )), + ARMv7_OP4(0x0e50, 0x00f0, 0x0040, 0x00d0, A1, LDRD_IMM), + ARMv7_OP4(0xfe7f, 0x0000, 0xe85f, 0x0000, T1, LDRD_LIT), + ARMv7_OP4(0x0f7f, 0x00f0, 0x014f, 0x00d0, A1, LDRD_LIT), + ARMv7_OP4(0x0e50, 0x0ff0, 0x0000, 0x00d0, A1, LDRD_REG), + + ARMv7_OP4(0xfff0, 0x0f00, 0xe850, 0x0f00, T1, LDREX), + ARMv7_OP4(0x0ff0, 0x0fff, 0x0190, 0x0f9f, A1, LDREX), + ARMv7_OP4(0xfff0, 0x0fff, 0xe8d0, 0x0f4f, T1, LDREXB), + ARMv7_OP4(0x0ff0, 0x0fff, 0x01d0, 0x0f9f, A1, LDREXB), + ARMv7_OP4(0xfff0, 0x00ff, 0xe8d0, 0x007f, T1, LDREXD), + ARMv7_OP4(0x0ff0, 0x0fff, 0x01b0, 0x0f9f, A1, LDREXD), + ARMv7_OP4(0xfff0, 0x0fff, 0xe8d0, 0x0f5f, T1, LDREXH), + ARMv7_OP4(0x0ff0, 0x0fff, 0x01f0, 0x0f9f, A1, LDREXH), + + ARMv7_OP2(0xf800, 0x8800, T1, LDRH_IMM), + ARMv7_OP4(0xfff0, 0x0000, 0xf8b0, 0x0000, T2, LDRH_IMM), + ARMv7_OP4(0xfff0, 0x0800, 0xf830, 0x0800, T3, LDRH_IMM), + ARMv7_OP4(0x0e50, 0x00f0, 0x0050, 0x00b0, A1, LDRH_IMM), + ARMv7_OP4(0xff7f, 0x0000, 0xf83f, 0x0000, T1, LDRH_LIT), + ARMv7_OP4(0x0f7f, 0x00f0, 0x015f, 0x00b0, A1, LDRH_LIT), + ARMv7_OP2(0xfe00, 0x5a00, T1, LDRH_REG), + ARMv7_OP4(0xfff0, 0x0fc0, 0xf830, 0x0000, T2, LDRH_REG), + ARMv7_OP4(0x0e50, 0x0ff0, 0x0010, 0x00b0, A1, LDRH_REG), + + ARMv7_OP4(0xfff0, 0x0000, 0xf990, 0x0000, T1, LDRSB_IMM), + ARMv7_OP4(0xfff0, 0x0800, 0xf910, 0x0800, T2, LDRSB_IMM), + ARMv7_OP4(0x0e50, 0x00f0, 0x0050, 0x00d0, A1, LDRSB_IMM), + ARMv7_OP4(0xff7f, 0x0000, 0xf91f, 0x0000, T1, LDRSB_LIT), + ARMv7_OP4(0x0f7f, 0x00f0, 0x015f, 0x00d0, A1, LDRSB_LIT), + ARMv7_OP2(0xfe00, 0x5600, T1, LDRSB_REG), + ARMv7_OP4(0xfff0, 0x0fc0, 0xf910, 0x0000, T2, LDRSB_REG), + ARMv7_OP4(0x0e50, 0x0ff0, 0x0010, 0x00d0, A1, LDRSB_REG), + + ARMv7_OP4(0xfff0, 0x0000, 0xf9b0, 0x0000, T1, LDRSH_IMM), + ARMv7_OP4(0xfff0, 0x0800, 0xf930, 0x0800, T2, LDRSH_IMM), + ARMv7_OP4(0x0e50, 0x00f0, 0x0050, 0x00f0, A1, LDRSH_IMM), + ARMv7_OP4(0xff7f, 0x0000, 0xf93f, 0x0000, T1, LDRSH_LIT), + ARMv7_OP4(0x0f7f, 0x00f0, 0x015f, 0x00f0, A1, LDRSH_LIT), + ARMv7_OP2(0xfe00, 0x5e00, T1, LDRSH_REG), + ARMv7_OP4(0xfff0, 0x0fc0, 0xf930, 0x0000, T2, LDRSH_REG), + ARMv7_OP4(0x0e50, 0x0ff0, 0x0010, 0x00f0, A1, LDRSH_REG), + + ARMv7_OP2(0xf800, 0x0000, T1, LSL_IMM), + ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0000, T2, LSL_IMM), + ARMv7_OP4(0x0fef, 0x0070, 0x01a0, 0x0000, A1, LSL_IMM), + ARMv7_OP2(0xffc0, 0x4080, T1, LSL_REG), + ARMv7_OP4(0xffe0, 0xf0f0, 0xfa00, 0xf000, T2, LSL_REG), + ARMv7_OP4(0x0fef, 0x00f0, 0x01a0, 0x0010, A1, LSL_REG), + + ARMv7_OP2(0xf800, 0x0800, T1, LSR_IMM), + ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0010, T2, LSR_IMM), + ARMv7_OP4(0x0fef, 0x0030, 0x01a0, 0x0020, A1, LSR_IMM), + ARMv7_OP2(0xffc0, 0x40c0, T1, LSR_REG), + ARMv7_OP4(0xffe0, 0xf0f0, 0xfa20, 0xf000, T2, LSR_REG), + ARMv7_OP4(0x0fef, 0x00f0, 0x01a0, 0x0030, A1, LSR_REG), + + ARMv7_OP4(0xfff0, 0x00f0, 0xfb00, 0x0000, T1, MLA, SKIP_IF( BF(12, 15) == 15 )), + ARMv7_OP4(0x0fe0, 0x00f0, 0x0020, 0x0090, A1, MLA), + + ARMv7_OP4(0xfff0, 0x00f0, 0xfb00, 0x0010, T1, MLS), + ARMv7_OP4(0x0ff0, 0x00f0, 0x0060, 0x0090, A1, MLS), + + ARMv7_OP2(0xf800, 0x2000, T1, MOV_IMM), + ARMv7_OP4(0xfbef, 0x8000, 0xf04f, 0x0000, T2, MOV_IMM), + ARMv7_OP4(0xfbf0, 0x8000, 0xf240, 0x0000, T3, MOV_IMM), + ARMv7_OP4(0x0fef, 0x0000, 0x03a0, 0x0000, A1, MOV_IMM), + ARMv7_OP4(0x0ff0, 0x0000, 0x0300, 0x0000, A2, MOV_IMM), + ARMv7_OP2(0xff00, 0x4600, T1, MOV_REG), + ARMv7_OP2(0xffc0, 0x0000, T2, MOV_REG), + ARMv7_OP4(0xffef, 0xf0f0, 0xea4f, 0x0000, T3, MOV_REG), + ARMv7_OP4(0x0fef, 0x0ff0, 0x01a0, 0x0000, A1, MOV_REG), + + ARMv7_OP4(0xfbf0, 0x8000, 0xf2c0, 0x0000, T1, MOVT), + ARMv7_OP4(0x0ff0, 0x0000, 0x0340, 0x0000, A1, MOVT), + + ARMv7_OP4(0xff10, 0x0010, 0xee10, 0x0010, T1, MRC_), + ARMv7_OP4(0x0f10, 0x0010, 0x0e10, 0x0010, A1, MRC_), + ARMv7_OP4(0xff10, 0x0010, 0xfe10, 0x0010, T2, MRC_), + ARMv7_OP4(0xff10, 0x0010, 0xfe10, 0x0010, A2, MRC_), + + ARMv7_OP4(0xffff, 0xf0ff, 0xf3ef, 0x8000, T1, MRS), + ARMv7_OP4(0x0fff, 0x0fff, 0x010f, 0x0000, A1, MRS), + + ARMv7_OP4(0x0ff3, 0xf000, 0x0320, 0xf000, A1, MSR_IMM), + ARMv7_OP4(0xfff0, 0xf3ff, 0xf380, 0x8000, T1, MSR_REG), + ARMv7_OP4(0x0ff3, 0xfff0, 0x0120, 0xf000, A1, MSR_REG), + + ARMv7_OP2(0xffc0, 0x4340, T1, MUL), + ARMv7_OP4(0xfff0, 0xf0f0, 0xfb00, 0xf000, T2, MUL), + ARMv7_OP4(0x0fe0, 0xf0f0, 0x0000, 0x0090, A1, MUL), + + ARMv7_OP4(0xfbef, 0x8000, 0xf06f, 0x0000, T1, MVN_IMM), + ARMv7_OP4(0x0fef, 0x0000, 0x03e0, 0x0000, A1, MVN_IMM), + ARMv7_OP2(0xffc0, 0x43c0, T1, MVN_REG), + ARMv7_OP4(0xffef, 0x8000, 0xea6f, 0x0000, T2, MVN_REG), + ARMv7_OP4(0xffef, 0x0010, 0x01e0, 0x0000, A1, MVN_REG), + ARMv7_OP4(0x0fef, 0x0090, 0x01e0, 0x0010, A1, MVN_RSR), + + ARMv7_OP2(0xffff, 0xbf00, T1, NOP), + ARMv7_OP4(0xffff, 0xffff, 0xf3af, 0x8000, T2, NOP), + ARMv7_OP4(0x0fff, 0xffff, 0x0320, 0xf000, A1, NOP), + + ARMv7_OP4(0xfbe0, 0x8000, 0xf060, 0x0000, T1, ORN_IMM), + ARMv7_OP4(0xffe0, 0x8000, 0xea60, 0x0000, T1, ORN_REG), + + ARMv7_OP4(0xfbe0, 0x8000, 0xf040, 0x0000, T1, ORR_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x0380, 0x0000, A1, ORR_IMM), + ARMv7_OP2(0xffc0, 0x4300, T1, ORR_REG), + ARMv7_OP4(0xffe0, 0x8000, 0xea40, 0x0000, T2, ORR_REG), + ARMv7_OP4(0x0fe0, 0x0010, 0x0180, 0x0000, A1, ORR_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x0180, 0x0010, A1, ORR_RSR), + + ARMv7_OP4(0xfff0, 0x8010, 0xeac0, 0x0000, T1, PKH), + ARMv7_OP4(0x0ff0, 0x0030, 0x0680, 0x0010, A1, PKH), + + ARMv7_OP2(0xfe00, 0xbc00, T1, POP), + ARMv7_OP4(0xffff, 0x0000, 0xe8bd, 0x0000, T2, POP), + ARMv7_OP4(0xffff, 0x0fff, 0xf85d, 0x0b04, T3, POP), + ARMv7_OP4(0x0fff, 0x0000, 0x08bd, 0x0000, A1, POP), + ARMv7_OP4(0x0fff, 0x0fff, 0x049d, 0x0004, A2, POP), + + ARMv7_OP2(0xfe00, 0xb400, T1, PUSH), + ARMv7_OP4(0xffff, 0x0000, 0xe92d, 0x0000, T2, PUSH), // had an error in arch ref + ARMv7_OP4(0xffff, 0x0fff, 0xf84d, 0x0d04, T3, PUSH), + ARMv7_OP4(0x0fff, 0x0000, 0x092d, 0x0000, A1, PUSH), + ARMv7_OP4(0x0fff, 0x0fff, 0x052d, 0x0004, A2, PUSH), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf080, T1, QADD), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0100, 0x0050, A1, QADD), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf010, T1, QADD16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0620, 0x0f10, A1, QADD16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf010, T1, QADD8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0620, 0x0f90, A1, QADD8), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf010, T1, QASX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0620, 0x0f30, A1, QASX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf090, T1, QDADD), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0140, 0x0050, A1, QDADD), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf0b0, T1, QDSUB), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0160, 0x0050, A1, QDSUB), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfae0, 0xf010, T1, QSAX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0620, 0x0f50, A1, QSAX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf0a0, T1, QSUB), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0120, 0x0050, A1, QSUB), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfad0, 0xf010, T1, QSUB16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0620, 0x0f70, A1, QSUB16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfac0, 0xf010, T1, QSUB8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0620, 0x0ff0, A1, QSUB8), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf0a0, T1, RBIT), + ARMv7_OP4(0x0fff, 0x0ff0, 0x06ff, 0x0f30, A1, RBIT), + + ARMv7_OP2(0xffc0, 0xba00, T1, REV), + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf080, T2, REV), + ARMv7_OP4(0x0fff, 0x0ff0, 0x06bf, 0x0f30, A1, REV), + + ARMv7_OP2(0xffc0, 0xba40, T1, REV16), + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf090, T2, REV16), + ARMv7_OP4(0x0fff, 0x0ff0, 0x06bf, 0x0fb0, A1, REV16), + + ARMv7_OP2(0xffc0, 0xbac0, T1, REVSH), + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf0b0, T2, REVSH), + ARMv7_OP4(0x0fff, 0x0ff0, 0x06ff, 0x0fb0, A1, REVSH), + + ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0030, T1, ROR_IMM), + ARMv7_OP4(0x0fef, 0x0070, 0x01a0, 0x0060, A1, ROR_IMM), + ARMv7_OP2(0xffc0, 0x41c0, T1, ROR_REG), + ARMv7_OP4(0xffe0, 0xf0f0, 0xfa60, 0xf000, T2, ROR_REG), + ARMv7_OP4(0x0fef, 0x00f0, 0x01a0, 0x0070, A1, ROR_REG), + ARMv7_OP4(0xffef, 0xf0f0, 0xea4f, 0x0030, T1, RRX), + ARMv7_OP4(0x0fef, 0x0ff0, 0x01a0, 0x0060, A1, RRX), + + ARMv7_OP2(0xffc0, 0x4240, T1, RSB_IMM), + ARMv7_OP4(0xfbe0, 0x8000, 0xf1c0, 0x0000, T2, RSB_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x0260, 0x0000, A1, RSB_IMM), + ARMv7_OP4(0xffe0, 0x8000, 0xebc0, 0x0000, T1, RSB_REG), + ARMv7_OP4(0x0fe0, 0x0010, 0x0060, 0x0000, A1, RSB_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x0060, 0x0010, A1, RSB_RSR), + + ARMv7_OP4(0x0fe0, 0x0000, 0x02e0, 0x0000, A1, RSC_IMM), + ARMv7_OP4(0x0fe0, 0x0010, 0x00e0, 0x0000, A1, RSC_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x00e0, 0x0010, A1, RSC_RSR), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf000, T1, SADD16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0610, 0x0f10, A1, SADD16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf000, T1, SADD8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0610, 0x0f90, A1, SADD8), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf000, T1, SASX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0610, 0x0f30, A1, SASX), + + ARMv7_OP4(0xfbe0, 0x8000, 0xf160, 0x0000, T1, SBC_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x02c0, 0x0000, A1, SBC_IMM), + ARMv7_OP2(0xffc0, 0x4180, T1, SBC_REG), + ARMv7_OP4(0xffe0, 0x8000, 0xeb60, 0x0000, T2, SBC_REG), + ARMv7_OP4(0x0fe0, 0x0010, 0x00c0, 0x0000, A1, SBC_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x00c0, 0x0010, A1, SBC_RSR), + + ARMv7_OP4(0xfff0, 0x8020, 0xf340, 0x0000, T1, SBFX), + ARMv7_OP4(0x0fe0, 0x0070, 0x07a0, 0x0050, A1, SBFX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfb90, 0xf0f0, T1, SDIV), // ??? + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf080, T1, SEL), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0680, 0x0fb0, A1, SEL), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf020, T1, SHADD16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0630, 0x0f10, A1, SHADD16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf020, T1, SHADD8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0630, 0x0f90, A1, SHADD8), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf020, T1, SHASX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0630, 0x0f30, A1, SHASX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfae0, 0xf020, T1, SHSAX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0630, 0x0f50, A1, SHSAX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfad0, 0xf020, T1, SHSUB16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0630, 0x0f70, A1, SHSUB16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfac0, 0xf020, T1, SHSUB8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0630, 0x0ff0, A1, SHSUB8), + + ARMv7_OP4(0xfff0, 0x00c0, 0xfb10, 0x0000, T1, SMLA__), + ARMv7_OP4(0x0ff0, 0x0090, 0x0100, 0x0080, A1, SMLA__), + + ARMv7_OP4(0xfff0, 0x00e0, 0xfb20, 0x0000, T1, SMLAD), + ARMv7_OP4(0x0ff0, 0x00d0, 0x0700, 0x0010, A1, SMLAD), + + ARMv7_OP4(0xfff0, 0x00f0, 0xfbc0, 0x0000, T1, SMLAL), + ARMv7_OP4(0x0fe0, 0x00f0, 0x00e0, 0x0090, A1, SMLAL), + + ARMv7_OP4(0xfff0, 0x00c0, 0xfbc0, 0x0080, T1, SMLAL__), + ARMv7_OP4(0x0ff0, 0x0090, 0x0140, 0x0080, A1, SMLAL__), + + ARMv7_OP4(0xfff0, 0x00e0, 0xfbc0, 0x00c0, T1, SMLALD), + ARMv7_OP4(0x0ff0, 0x00d0, 0x0740, 0x0010, A1, SMLALD), + + ARMv7_OP4(0xfff0, 0x00e0, 0xfb30, 0x0000, T1, SMLAW_), + ARMv7_OP4(0x0ff0, 0x00b0, 0x0120, 0x0080, A1, SMLAW_), + + ARMv7_OP4(0xfff0, 0x00e0, 0xfb40, 0x0000, T1, SMLSD), + ARMv7_OP4(0x0ff0, 0x00d0, 0x0700, 0x0050, A1, SMLSD), + + ARMv7_OP4(0xfff0, 0x00e0, 0xfbd0, 0x00c0, T1, SMLSLD), + ARMv7_OP4(0x0ff0, 0x00d0, 0x0740, 0x0050, A1, SMLSLD), + + ARMv7_OP4(0xfff0, 0x00e0, 0xfb50, 0x0000, T1, SMMLA), + ARMv7_OP4(0x0ff0, 0x00d0, 0x0750, 0x0010, A1, SMMLA), + + ARMv7_OP4(0xfff0, 0x00e0, 0xfb60, 0x0000, T1, SMMLS), + ARMv7_OP4(0x0ff0, 0x00d0, 0x0750, 0x00d0, A1, SMMLS), + + ARMv7_OP4(0xfff0, 0xf0e0, 0xfb50, 0xf000, T1, SMMUL), + ARMv7_OP4(0x0ff0, 0xf0d0, 0x0750, 0xf010, A1, SMMUL), + + ARMv7_OP4(0xfff0, 0xf0e0, 0xfb20, 0xf000, T1, SMUAD), + ARMv7_OP4(0x0ff0, 0xf0d0, 0x0700, 0xf010, A1, SMUAD), + + ARMv7_OP4(0xfff0, 0xf0c0, 0xfb10, 0xf000, T1, SMUL__), + ARMv7_OP4(0x0ff0, 0xf090, 0x0160, 0x0080, A1, SMUL__), + + ARMv7_OP4(0xfff0, 0x00f0, 0xfb80, 0x0000, T1, SMULL), + ARMv7_OP4(0x0fe0, 0x00f0, 0x00c0, 0x0090, A1, SMULL), + + ARMv7_OP4(0xfff0, 0xf0e0, 0xfb30, 0xf000, T1, SMULW_), + ARMv7_OP4(0x0ff0, 0xf0b0, 0x0120, 0x00a0, A1, SMULW_), + + ARMv7_OP4(0xfff0, 0xf0e0, 0xfb40, 0xf000, T1, SMUSD), + ARMv7_OP4(0x0ff0, 0xf0d0, 0x0700, 0xf050, A1, SMUSD), + + ARMv7_OP4(0xffd0, 0x8020, 0xf300, 0x0000, T1, SSAT), + ARMv7_OP4(0x0fe0, 0x0030, 0x06a0, 0x0010, A1, SSAT), + + ARMv7_OP4(0xfff0, 0xf0e0, 0xf320, 0x0000, T1, SSAT16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x06a0, 0x0f30, A1, SSAT16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfae0, 0xf000, T1, SSAX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0610, 0x0f50, A1, SSAX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfad0, 0xf000, T1, SSUB16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0610, 0x0f70, A1, SSUB16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfac0, 0xf000, T1, SSUB8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0610, 0x0ff0, A1, SSUB8), + + ARMv7_OP2(0xf800, 0xc000, T1, STM), + ARMv7_OP4(0xffd0, 0xa000, 0xe880, 0x0000, T2, STM), + ARMv7_OP4(0x0fd0, 0x0000, 0x0880, 0x0000, A1, STM), + ARMv7_OP4(0x0fd0, 0x0000, 0x0800, 0x0000, A1, STMDA), + ARMv7_OP4(0xffd0, 0xa000, 0xe900, 0x0000, T1, STMDB), + ARMv7_OP4(0x0fd0, 0x0000, 0x0900, 0x0000, A1, STMDB), + ARMv7_OP4(0x0fd0, 0x0000, 0x0980, 0x0000, A1, STMIB), + + ARMv7_OP2(0xf800, 0x6000, T1, STR_IMM), + ARMv7_OP2(0xf800, 0x9000, T2, STR_IMM), + ARMv7_OP4(0xfff0, 0x0000, 0xf8c0, 0x0000, T3, STR_IMM), + ARMv7_OP4(0xfff0, 0x0800, 0xf840, 0x0800, T4, STR_IMM), + ARMv7_OP4(0x0e50, 0x0000, 0x0400, 0x0000, A1, STR_IMM), + ARMv7_OP2(0xfe00, 0x5000, T1, STR_REG), + ARMv7_OP4(0xfff0, 0x0fc0, 0xf840, 0x0000, T2, STR_REG), + ARMv7_OP4(0x0e50, 0x0010, 0x0600, 0x0000, A1, STR_REG), + + ARMv7_OP2(0xf800, 0x7000, T1, STRB_IMM), + ARMv7_OP4(0xfff0, 0x0000, 0xf880, 0x0000, T2, STRB_IMM), + ARMv7_OP4(0xfff0, 0x0800, 0xf800, 0x0800, T3, STRB_IMM), + ARMv7_OP4(0x0e50, 0x0000, 0x0440, 0x0000, A1, STRB_IMM), + ARMv7_OP2(0xfe00, 0x5400, T1, STRB_REG), + ARMv7_OP4(0xfff0, 0x0fc0, 0xf800, 0x0000, T2, STRB_REG), + ARMv7_OP4(0x0e50, 0x0010, 0x0640, 0x0000, A1, STRB_REG), + + ARMv7_OP4(0xfe50, 0x0000, 0xe840, 0x0000, T1, STRD_IMM, SKIP_IF( !BT(21) && !BT(24) )), + ARMv7_OP4(0x0e50, 0x00f0, 0x0040, 0x00f0, A1, STRD_IMM), + ARMv7_OP4(0x0e50, 0x0ff0, 0x0000, 0x00f0, A1, STRD_REG), + + ARMv7_OP4(0xfff0, 0x0000, 0xe840, 0x0000, T1, STREX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0180, 0x0f90, A1, STREX), + ARMv7_OP4(0xfff0, 0x0ff0, 0xe8c0, 0x0f40, T1, STREXB), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x01c0, 0x0f90, A1, STREXB), + ARMv7_OP4(0xfff0, 0x00f0, 0xe8c0, 0x0070, T1, STREXD), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x01a0, 0x0f90, A1, STREXD), + ARMv7_OP4(0xfff0, 0x0ff0, 0xe8c0, 0x0f50, T1, STREXH), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x01e0, 0x0f90, A1, STREXH), + + ARMv7_OP2(0xf800, 0x8000, T1, STRH_IMM), + ARMv7_OP4(0xfff0, 0x0000, 0xf8a0, 0x0000, T2, STRH_IMM), + ARMv7_OP4(0xfff0, 0x0800, 0xf820, 0x0800, T3, STRH_IMM), + ARMv7_OP4(0x0e50, 0x00f0, 0x0040, 0x00b0, A1, STRH_IMM), + ARMv7_OP2(0xfe00, 0x5200, T1, STRH_REG), + ARMv7_OP4(0xfff0, 0x0fc0, 0xf820, 0x0000, T2, STRH_REG), + ARMv7_OP4(0x0e50, 0x0ff0, 0x0000, 0x00b0, A1, STRH_REG), + + ARMv7_OP2(0xfe00, 0x1e00, T1, SUB_IMM), + ARMv7_OP2(0xf800, 0x3800, T2, SUB_IMM), + ARMv7_OP4(0xfbe0, 0x8000, 0xf1a0, 0x0000, T3, SUB_IMM, SKIP_IF( (BF(8, 11) == 15 && BT(20)) || BF(16, 19) == 13 )), + ARMv7_OP4(0xfbf0, 0x8000, 0xf2a0, 0x0000, T4, SUB_IMM), + ARMv7_OP4(0x0fe0, 0x0000, 0x0240, 0x0000, A1, SUB_IMM), + ARMv7_OP2(0xfe00, 0x1a00, T1, SUB_REG), + ARMv7_OP4(0xffe0, 0x8000, 0xeba0, 0x0000, T2, SUB_REG, SKIP_IF( (BF(8, 11) == 15 && BT(20)) || BF(16, 19) == 13 )), + ARMv7_OP4(0x0fe0, 0x0010, 0x0040, 0x0000, A1, SUB_REG), + ARMv7_OP4(0x0fe0, 0x0090, 0x0040, 0x0010, A1, SUB_RSR), + ARMv7_OP2(0xff80, 0xb080, T1, SUB_SPI), + ARMv7_OP4(0xfbef, 0x8000, 0xf1ad, 0x0000, T2, SUB_SPI), + ARMv7_OP4(0xfbff, 0x8000, 0xf2ad, 0x0000, T3, SUB_SPI), + ARMv7_OP4(0x0fef, 0x0000, 0x024d, 0x0000, A1, SUB_SPI), + ARMv7_OP4(0xffef, 0x8000, 0xebad, 0x0000, T1, SUB_SPR), + ARMv7_OP4(0x0fef, 0x0010, 0x004d, 0x0000, A1, SUB_SPR), + + ARMv7_OP2(0xff00, 0xdf00, T1, SVC), + ARMv7_OP4(0x0f00, 0x0000, 0x0f00, 0x0000, A1, SVC), + + ARMv7_OP4(0xfff0, 0xf0c0, 0xfa40, 0xf080, T1, SXTAB), + ARMv7_OP4(0x0ff0, 0x03f0, 0x06a0, 0x0070, A1, SXTAB), + + ARMv7_OP4(0xfff0, 0xf0c0, 0xfa20, 0xf080, T1, SXTAB16), + ARMv7_OP4(0x0ff0, 0x03f0, 0x0680, 0x0070, A1, SXTAB16), + + ARMv7_OP4(0xfff0, 0xf0c0, 0xfa00, 0xf080, T1, SXTAH), + ARMv7_OP4(0x0ff0, 0x03f0, 0x06b0, 0x0070, A1, SXTAH), + + ARMv7_OP2(0xffc0, 0xb240, T1, SXTB), + ARMv7_OP4(0xffff, 0xf0c0, 0xfa4f, 0xf080, T2, SXTB), + ARMv7_OP4(0x0fff, 0x03f0, 0x06af, 0x0070, A1, SXTB), + + ARMv7_OP4(0xffff, 0xf0c0, 0xfa2f, 0xf080, T1, SXTB16), + ARMv7_OP4(0x0fff, 0x03f0, 0x068f, 0x0070, A1, SXTB16), + + ARMv7_OP2(0xffc0, 0xb200, T1, SXTH), + ARMv7_OP4(0xffff, 0xf0c0, 0xfa0f, 0xf080, T2, SXTH), + ARMv7_OP4(0x0fff, 0x03f0, 0x06bf, 0x0070, A1, SXTH), + + ARMv7_OP4(0xfff0, 0xffe0, 0xe8d0, 0xf000, T1, TB_), + + ARMv7_OP4(0xfbf0, 0x8f00, 0xf090, 0x0f00, T1, TEQ_IMM), + ARMv7_OP4(0x0ff0, 0xf000, 0x0330, 0x0000, A1, TEQ_IMM), + ARMv7_OP4(0xfff0, 0x8f00, 0xea90, 0x0f00, T1, TEQ_REG), + ARMv7_OP4(0x0ff0, 0xf010, 0x0130, 0x0000, A1, TEQ_REG), + ARMv7_OP4(0x0ff0, 0xf090, 0x0130, 0x0010, A1, TEQ_RSR), + + ARMv7_OP4(0xfbf0, 0x8f00, 0xf010, 0x0f00, T1, TST_IMM), + ARMv7_OP4(0x0ff0, 0xf000, 0x0310, 0x0000, A1, TST_IMM), + ARMv7_OP2(0xffc0, 0x4200, T1, TST_REG), + ARMv7_OP4(0xfff0, 0x8f00, 0xea10, 0x0f00, T2, TST_REG), + ARMv7_OP4(0x0ff0, 0xf010, 0x0110, 0x0000, A1, TST_REG), + ARMv7_OP4(0x0ff0, 0xf090, 0x0110, 0x0010, A1, TST_RSR), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf040, T1, UADD16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0650, 0x0f10, A1, UADD16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf040, T1, UADD8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0650, 0x0f90, A1, UADD8), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf040, T1, UASX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0650, 0x0f30, A1, UASX), + + ARMv7_OP4(0xfff0, 0x8020, 0xf3c0, 0x0000, T1, UBFX), + ARMv7_OP4(0x0fe0, 0x0070, 0x07e0, 0x0050, A1, UBFX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfbb0, 0xf0f0, T1, UDIV), // ??? + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf060, T1, UHADD16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0670, 0x0f10, A1, UHADD16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf060, T1, UHADD8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0670, 0x0f90, A1, UHADD8), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf060, T1, UHASX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0670, 0x0f30, A1, UHASX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfae0, 0xf060, T1, UHSAX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0670, 0x0f50, A1, UHSAX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfad0, 0xf060, T1, UHSUB16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0670, 0x0f70, A1, UHSUB16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfac0, 0xf060, T1, UHSUB8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0670, 0x0ff0, A1, UHSUB8), + + ARMv7_OP4(0xfff0, 0x00f0, 0xfbe0, 0x0060, T1, UMAAL), + ARMv7_OP4(0x0ff0, 0x00f0, 0x0040, 0x0090, A1, UMAAL), + + ARMv7_OP4(0xfff0, 0x00f0, 0xfbe0, 0x0000, T1, UMLAL), + ARMv7_OP4(0x0fe0, 0x00f0, 0x00a0, 0x0090, A1, UMLAL), + + ARMv7_OP4(0xfff0, 0x00f0, 0xfba0, 0x0000, T1, UMULL), + ARMv7_OP4(0x0fe0, 0x00f0, 0x0080, 0x0090, A1, UMULL), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf050, T1, UQADD16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0660, 0x0f10, A1, UQADD16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfa80, 0xf050, T1, UQADD8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0660, 0x0f90, A1, UQADD8), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf050, T1, UQASX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0660, 0x0f30, A1, UQASX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfae0, 0xf050, T1, UQSAX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0660, 0x0f50, A1, UQSAX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfad0, 0xf050, T1, UQSUB16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0660, 0x0f70, A1, UQSUB16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfac0, 0xf050, T1, UQSUB8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0660, 0x0ff0, A1, UQSUB8), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfb70, 0xf000, T1, USAD8), + ARMv7_OP4(0x0ff0, 0xf0f0, 0x0780, 0xf010, A1, USAD8), + + ARMv7_OP4(0xfff0, 0x00f0, 0xfb70, 0x0000, T1, USADA8), + ARMv7_OP4(0x0ff0, 0x00f0, 0x0780, 0x0010, A1, USADA8), + + ARMv7_OP4(0xffd0, 0x8020, 0xf380, 0x0000, T1, USAT), + ARMv7_OP4(0x0fe0, 0x0030, 0x06e0, 0x0010, A1, USAT), + + ARMv7_OP4(0xfff0, 0xf0e0, 0xf3a0, 0x0000, T1, USAT16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x06e0, 0x0f30, A1, USAT16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfae0, 0xf040, T1, USAX), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0650, 0x0f50, A1, USAX), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfad0, 0xf040, T1, USUB16), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0650, 0x0f70, A1, USUB16), + + ARMv7_OP4(0xfff0, 0xf0f0, 0xfac0, 0xf040, T1, USUB8), + ARMv7_OP4(0x0ff0, 0x0ff0, 0x0650, 0x0ff0, A1, USUB8), + + ARMv7_OP4(0xfff0, 0xf0c0, 0xfa50, 0xf080, T1, UXTAB), + ARMv7_OP4(0x0ff0, 0x03f0, 0x06e0, 0x0070, A1, UXTAB), + + ARMv7_OP4(0xfff0, 0xf0c0, 0xfa30, 0xf080, T1, UXTAB16), + ARMv7_OP4(0x0ff0, 0x03f0, 0x06c0, 0x0070, A1, UXTAB16), + + ARMv7_OP4(0xfff0, 0xf0c0, 0xfa10, 0xf080, T1, UXTAH), + ARMv7_OP4(0x0ff0, 0x03f0, 0x06f0, 0x0070, A1, UXTAH), + + ARMv7_OP2(0xffc0, 0xb2c0, T1, UXTB), + ARMv7_OP4(0xffff, 0xf0c0, 0xfa5f, 0xf080, T2, UXTB), + ARMv7_OP4(0x0fff, 0x03f0, 0x06ef, 0x0070, A1, UXTB), + + ARMv7_OP4(0xffff, 0xf0c0, 0xfa3f, 0xf080, T1, UXTB16), + ARMv7_OP4(0x0fff, 0x03f0, 0x06cf, 0x0070, A1, UXTB16), + + ARMv7_OP2(0xffc0, 0xb280, T1, UXTH), + ARMv7_OP4(0xffff, 0xf0c0, 0xfa1f, 0xf080, T2, UXTH), + ARMv7_OP4(0x0fff, 0x03f0, 0x06ff, 0x0070, A1, UXTH), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0710, T1, VABA_), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0710, A1, VABA_), + ARMv7_OP4(0xef80, 0x0f50, 0xef80, 0x0500, T2, VABA_), + ARMv7_OP4(0xfe80, 0x0f50, 0xf280, 0x0500, A2, VABA_), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0700, T1, VABD_), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0700, A1, VABD_), + ARMv7_OP4(0xef80, 0x0f50, 0xef80, 0x0700, T2, VABD_), + ARMv7_OP4(0xfe80, 0x0f50, 0xf280, 0x0700, A2, VABD_), + + ARMv7_OP4(0xffa0, 0x0f10, 0xff20, 0x0d00, T1, VABD_FP), + ARMv7_OP4(0xffa0, 0x0f10, 0xf320, 0x0d00, A1, VABD_FP), + + ARMv7_OP4(0xffb3, 0x0b90, 0xffb1, 0x0300, T1, VABS), + ARMv7_OP4(0xffb3, 0x0b90, 0xf3b1, 0x0300, A1, VABS), + ARMv7_OP4(0xffbf, 0x0ed0, 0xeeb0, 0x0ac0, T2, VABS), + ARMv7_OP4(0x0fbf, 0x0ed0, 0x0eb0, 0x0ac0, A2, VABS), + + ARMv7_OP4(0xff80, 0x0f10, 0xff00, 0x0e10, T1, VAC__), + ARMv7_OP4(0xff80, 0x0f10, 0xf300, 0x0e10, A1, VAC__), + + ARMv7_OP4(0xff80, 0x0f10, 0xef00, 0x0800, T1, VADD), + ARMv7_OP4(0xff80, 0x0f10, 0xf200, 0x0800, A1, VADD), + + ARMv7_OP4(0xffa0, 0x0f10, 0xef00, 0x0d00, T1, VADD_FP), + ARMv7_OP4(0xffa0, 0x0f10, 0xf200, 0x0d00, A1, VADD_FP), + ARMv7_OP4(0xffb0, 0x0e50, 0xee30, 0x0a00, T2, VADD_FP), + ARMv7_OP4(0x0fb0, 0x0e50, 0x0e30, 0x0a00, A2, VADD_FP), + + ARMv7_OP4(0xff80, 0x0f50, 0xef80, 0x0400, T1, VADDHN), + ARMv7_OP4(0xff80, 0x0f50, 0xf280, 0x0400, A1, VADDHN), + + ARMv7_OP4(0xef80, 0x0e50, 0xef80, 0x0000, T1, VADD_), + ARMv7_OP4(0xfe80, 0x0e50, 0xf280, 0x0000, A1, VADD_), + + ARMv7_OP4(0xffb0, 0x0f10, 0xef00, 0x0110, T1, VAND), + ARMv7_OP4(0xffb0, 0x0f10, 0xf200, 0x0110, A1, VAND), + + ARMv7_OP4(0xefb8, 0x00b0, 0xef80, 0x0030, T1, VBIC_IMM), + ARMv7_OP4(0xfeb0, 0x00b0, 0xf280, 0x0030, A1, VBIC_IMM), + + ARMv7_OP4(0xffb0, 0x0f10, 0xef10, 0x0110, T1, VBIC_REG), + ARMv7_OP4(0xffb0, 0x0f10, 0xf210, 0x0110, A1, VBIC_REG), + + ARMv7_OP4(0xff80, 0x0f10, 0xff00, 0x0110, T1, VB__), + ARMv7_OP4(0xff80, 0x0f10, 0xf300, 0x0110, A1, VB__), + + ARMv7_OP4(0xff80, 0x0f10, 0xff00, 0x0810, T1, VCEQ_REG), + ARMv7_OP4(0xff80, 0x0f10, 0xf300, 0x0810, A1, VCEQ_REG), + ARMv7_OP4(0xffa0, 0x0f10, 0xef00, 0x0e00, T2, VCEQ_REG), + ARMv7_OP4(0xffa0, 0x0f10, 0xf200, 0x0e00, A2, VCEQ_REG), + + ARMv7_OP4(0xffb3, 0x0b90, 0xffb1, 0x0100, T1, VCEQ_ZERO), + ARMv7_OP4(0xffb3, 0x0b90, 0xf3b1, 0x0100, A1, VCEQ_ZERO), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0310, T1, VCGE_REG), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0310, A1, VCGE_REG), + ARMv7_OP4(0xffa0, 0x0f10, 0xff00, 0x0e00, T2, VCGE_REG), + ARMv7_OP4(0xffa0, 0x0f10, 0xf300, 0x0e00, A2, VCGE_REG), + + ARMv7_OP4(0xffb3, 0x0b90, 0xffb1, 0x0080, T1, VCGE_ZERO), + ARMv7_OP4(0xffb3, 0x0b90, 0xf3b1, 0x0080, A1, VCGE_ZERO), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0300, T1, VCGT_REG), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0300, A1, VCGT_REG), + ARMv7_OP4(0xffa0, 0x0f10, 0xff20, 0x0e00, T2, VCGT_REG), + ARMv7_OP4(0xffa0, 0x0f10, 0xf320, 0x0e00, A2, VCGT_REG), + + ARMv7_OP4(0xffb3, 0x0b90, 0xffb1, 0x0000, T1, VCGT_ZERO), + ARMv7_OP4(0xffb3, 0x0b90, 0xf3b1, 0x0000, A1, VCGT_ZERO), + + ARMv7_OP4(0xffb3, 0x0b90, 0xffb1, 0x0180, T1, VCLE_ZERO), + ARMv7_OP4(0xffb3, 0x0b90, 0xf3b1, 0x0180, A1, VCLE_ZERO), + + ARMv7_OP4(0xffb3, 0x0f90, 0xffb0, 0x0400, T1, VCLS), + ARMv7_OP4(0xffb3, 0x0f90, 0xf3b0, 0x0400, A1, VCLS), + + ARMv7_OP4(0xffb3, 0x0b90, 0xffb1, 0x0200, T1, VCLT_ZERO), + ARMv7_OP4(0xffb3, 0x0b90, 0xf3b1, 0x0200, A1, VCLT_ZERO), + + ARMv7_OP4(0xffb3, 0x0f90, 0xffb0, 0x0480, T1, VCLZ), + ARMv7_OP4(0xffb3, 0x0f90, 0xf3b0, 0x0480, A1, VCLZ), + + ARMv7_OP4(0xffbf, 0x0e50, 0xeeb4, 0x0a40, T1, VCMP_), + ARMv7_OP4(0x0fbf, 0x0e50, 0x0eb4, 0x0a40, A1, VCMP_), + ARMv7_OP4(0xffbf, 0x0e7f, 0xeeb5, 0x0a40, T2, VCMP_), + ARMv7_OP4(0x0fbf, 0x0e7f, 0x0eb5, 0x0a40, A2, VCMP_), + + ARMv7_OP4(0xffb3, 0x0f90, 0xffb0, 0x0500, T1, VCNT), + ARMv7_OP4(0xffb3, 0x0f90, 0xf3b0, 0x0500, A1, VCNT), + + ARMv7_OP4(0xffb3, 0x0e10, 0xffb3, 0x0600, T1, VCVT_FIA), + ARMv7_OP4(0xffb3, 0x0e10, 0xf3b3, 0x0600, A1, VCVT_FIA), + + ARMv7_OP4(0xffb8, 0x0e50, 0xeeb8, 0x0a40, T1, VCVT_FIF), + ARMv7_OP4(0x0fb8, 0x0e50, 0x0eb8, 0x0a40, A1, VCVT_FIF), + + ARMv7_OP4(0xef80, 0x0e90, 0xef80, 0x0e10, T1, VCVT_FFA), + ARMv7_OP4(0xfe80, 0x0e90, 0xf280, 0x0e10, A1, VCVT_FFA), + + ARMv7_OP4(0xffba, 0x0e50, 0xeeba, 0x0a40, T1, VCVT_FFF), + ARMv7_OP4(0x0fba, 0x0e50, 0x0eba, 0x0a40, A1, VCVT_FFF), + + ARMv7_OP4(0xffbf, 0x0ed0, 0xeeb7, 0x0ac0, T1, VCVT_DF), + ARMv7_OP4(0x0fbf, 0x0ed0, 0x0eb7, 0x0ac0, A1, VCVT_DF), + + ARMv7_OP4(0xffb3, 0x0ed0, 0xffb2, 0x0600, T1, VCVT_HFA), + ARMv7_OP4(0xffb3, 0x0ed0, 0xf3b2, 0x0600, A1, VCVT_HFA), + + ARMv7_OP4(0xffbe, 0x0f50, 0xeeb2, 0x0a40, T1, VCVT_HFF), + ARMv7_OP4(0x0fbe, 0x0f50, 0x0eb2, 0x0a40, A1, VCVT_HFF), + + ARMv7_OP4(0xffb0, 0x0e50, 0xee80, 0x0a00, T1, VDIV), + ARMv7_OP4(0x0fb0, 0x0e50, 0x0e80, 0x0a00, A1, VDIV), + + ARMv7_OP4(0xffb0, 0x0f90, 0xffb0, 0x0c00, T1, VDUP_S), + ARMv7_OP4(0xffb0, 0x0f90, 0xf3b0, 0x0c00, A1, VDUP_S), + + ARMv7_OP4(0xff90, 0x0f5f, 0xee80, 0x0b10, T1, VDUP_R), + ARMv7_OP4(0x0f90, 0x0f5f, 0x0e80, 0x0b10, A1, VDUP_R), + + ARMv7_OP4(0xffb0, 0x0f10, 0xff00, 0x0110, T1, VEOR), + ARMv7_OP4(0xffb0, 0x0f10, 0xf300, 0x0110, A1, VEOR), + + ARMv7_OP4(0xffb0, 0x0010, 0xefb0, 0x0000, T1, VEXT), + ARMv7_OP4(0xffb0, 0x0010, 0xf2b0, 0x0000, A1, VEXT), + + ARMv7_OP4(0xef80, 0x0b10, 0xef00, 0x0000, T1, VHADDSUB), + ARMv7_OP4(0xfe80, 0x0b10, 0xf200, 0x0000, A1, VHADDSUB), + + ARMv7_OP4(0xffb0, 0x0000, 0xf920, 0x0000, T1, VLD__MS), // VLD1, VLD2, VLD3, VLD4 + ARMv7_OP4(0xffb0, 0x0000, 0xf420, 0x0000, A1, VLD__MS), + + ARMv7_OP4(0xffb0, 0x0f00, 0xf9a0, 0x0c00, T1, VLD1_SAL), + ARMv7_OP4(0xffb0, 0x0f00, 0xf4a0, 0x0c00, A1, VLD1_SAL), + + ARMv7_OP4(0xffb0, 0x0300, 0xf9a0, 0x0000, T1, VLD1_SL), + ARMv7_OP4(0xffb0, 0x0300, 0xf4a0, 0x0000, A1, VLD1_SL), + + ARMv7_OP4(0xffb0, 0x0f00, 0xf9a0, 0x0d00, T1, VLD2_SAL), + ARMv7_OP4(0xffb0, 0x0f00, 0xf4a0, 0x0d00, A1, VLD2_SAL), + + ARMv7_OP4(0xffb0, 0x0300, 0xf9a0, 0x0100, T1, VLD2_SL), + ARMv7_OP4(0xffb0, 0x0300, 0xf4a0, 0x0100, A1, VLD2_SL), + + ARMv7_OP4(0xffb0, 0x0f00, 0xf9a0, 0x0e00, T1, VLD3_SAL), + ARMv7_OP4(0xffb0, 0x0f00, 0xf4a0, 0x0e00, A1, VLD3_SAL), + + ARMv7_OP4(0xffb0, 0x0300, 0xf9a0, 0x0200, T1, VLD3_SL), + ARMv7_OP4(0xffb0, 0x0300, 0xf4a0, 0x0200, A1, VLD3_SL), + + ARMv7_OP4(0xffb0, 0x0f00, 0xf9a0, 0x0f00, T1, VLD4_SAL), + ARMv7_OP4(0xffb0, 0x0f00, 0xf4a0, 0x0f00, A1, VLD4_SAL), + + ARMv7_OP4(0xffb0, 0x0300, 0xf9a0, 0x0300, T1, VLD4_SL), + ARMv7_OP4(0xffb0, 0x0300, 0xf4a0, 0x0300, A1, VLD4_SL), + + ARMv7_OP4(0xfe10, 0x0f00, 0xec10, 0x0b00, T1, VLDM), + ARMv7_OP4(0x0e10, 0x0f00, 0x0c10, 0x0b00, A1, VLDM), + ARMv7_OP4(0xfe10, 0x0f00, 0xec10, 0x0a00, T2, VLDM), + ARMv7_OP4(0x0e10, 0x0f00, 0x0c10, 0x0a00, A2, VLDM), + + ARMv7_OP4(0xff30, 0x0f00, 0xed10, 0x0b00, T1, VLDR), + ARMv7_OP4(0x0f30, 0x0f00, 0x0d10, 0x0b00, A1, VLDR), + ARMv7_OP4(0xff30, 0x0f00, 0xed10, 0x0a00, T2, VLDR), + ARMv7_OP4(0x0f30, 0x0f00, 0x0d10, 0x0a00, A2, VLDR), + + ARMv7_OP4(0xef80, 0x0f00, 0xef00, 0x0600, T1, VMAXMIN), + ARMv7_OP4(0xfe80, 0x0f00, 0xf200, 0x0600, A1, VMAXMIN), + + ARMv7_OP4(0xff80, 0x0f10, 0xef00, 0x0f00, T1, VMAXMIN_FP), + ARMv7_OP4(0xff80, 0x0f10, 0xf200, 0x0f00, A1, VMAXMIN_FP), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0900, T1, VML__), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0900, A1, VML__), + ARMv7_OP4(0xef80, 0x0d50, 0xef80, 0x0800, T2, VML__), + ARMv7_OP4(0xfe80, 0x0d50, 0xf280, 0x0800, A2, VML__), + + ARMv7_OP4(0xff80, 0x0f10, 0xef00, 0x0d10, T1, VML__FP), + ARMv7_OP4(0xff80, 0x0f10, 0xf200, 0x0d10, A1, VML__FP), + ARMv7_OP4(0xffb0, 0x0e10, 0xee00, 0x0a00, T2, VML__FP), + ARMv7_OP4(0x0fb0, 0x0e10, 0x0e00, 0x0a00, A2, VML__FP), + + ARMv7_OP4(0xef80, 0x0a50, 0xef80, 0x0040, T1, VML__S), + ARMv7_OP4(0xfe80, 0x0a50, 0xf280, 0x0040, A1, VML__S), + ARMv7_OP4(0xef80, 0x0b50, 0xef80, 0x0240, T2, VML__S), + ARMv7_OP4(0xfe80, 0x0b50, 0xf280, 0x0240, A2, VML__S), + + ARMv7_OP4(0xefb8, 0x0090, 0xef80, 0x0010, T1, VMOV_IMM), + ARMv7_OP4(0xfeb8, 0x0090, 0xf280, 0x0010, A1, VMOV_IMM), + ARMv7_OP4(0xffb0, 0x0ef0, 0xeeb0, 0x0a00, T2, VMOV_IMM), + ARMv7_OP4(0x0fb0, 0x0ef0, 0x0eb0, 0x0a00, A2, VMOV_IMM), + + ARMv7_OP4(0xffb0, 0x0f10, 0xef20, 0x0110, T1, VMOV_REG), + ARMv7_OP4(0xffb0, 0x0f10, 0xf220, 0x0110, A1, VMOV_REG), + ARMv7_OP4(0xffbf, 0x0ed0, 0xeeb0, 0x0a40, T2, VMOV_REG), + ARMv7_OP4(0x0fbf, 0x0ed0, 0x0eb0, 0x0a40, A2, VMOV_REG), + + ARMv7_OP4(0xff90, 0x0f1f, 0xee00, 0x0b10, T1, VMOV_RS), + ARMv7_OP4(0x0f90, 0x0f1f, 0x0e00, 0x0b10, A1, VMOV_RS), + + ARMv7_OP4(0xff10, 0x0f1f, 0xee10, 0x0b10, T1, VMOV_SR), + ARMv7_OP4(0x0f10, 0x0f1f, 0x0e10, 0x0b10, A1, VMOV_SR), + + ARMv7_OP4(0xffe0, 0x0f7f, 0xee00, 0x0a10, T1, VMOV_RF), + ARMv7_OP4(0x0fe0, 0x0f7f, 0x0e00, 0x0a10, A1, VMOV_RF), + + ARMv7_OP4(0xffe0, 0x0fd0, 0xec40, 0x0a10, T1, VMOV_2RF), + ARMv7_OP4(0x0fe0, 0x0fd0, 0x0c40, 0x0a10, A1, VMOV_2RF), + + ARMv7_OP4(0xffe0, 0x0fd0, 0xec40, 0x0b10, T1, VMOV_2RD), + ARMv7_OP4(0x0fe0, 0x0fd0, 0x0c40, 0x0b10, A1, VMOV_2RD), + + ARMv7_OP4(0xef87, 0x0fd0, 0xef80, 0x0a10, T1, VMOVL), + ARMv7_OP4(0xfe87, 0x0fd0, 0xf280, 0x0a10, A1, VMOVL), + + ARMv7_OP4(0xffb3, 0x0fd0, 0xffb2, 0x0200, T1, VMOVN), + ARMv7_OP4(0xffb3, 0x0fd0, 0xf3b2, 0x0200, A1, VMOVN), + + ARMv7_OP4(0xffff, 0x0fff, 0xeef1, 0x0a10, T1, VMRS), + ARMv7_OP4(0x0fff, 0x0fff, 0x0ef1, 0x0a10, A1, VMRS), + + ARMv7_OP4(0xffff, 0x0fff, 0xeee1, 0x0a10, T1, VMSR), + ARMv7_OP4(0x0fff, 0x0fff, 0x0ee1, 0x0a10, A1, VMSR), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0910, T1, VMUL_), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0910, A1, VMUL_), + ARMv7_OP4(0xef80, 0x0d50, 0xef80, 0x0c00, T2, VMUL_), + ARMv7_OP4(0xfe80, 0x0d50, 0xf280, 0x0c00, A2, VMUL_), + + ARMv7_OP4(0xffa0, 0x0f10, 0xff00, 0x0d10, T1, VMUL_FP), + ARMv7_OP4(0xffa0, 0x0f10, 0xf300, 0x0d10, A1, VMUL_FP), + ARMv7_OP4(0xffb0, 0x0e50, 0xee20, 0x0a00, T2, VMUL_FP), + ARMv7_OP4(0x0fb0, 0x0e50, 0x0e20, 0x0a00, A2, VMUL_FP), + + ARMv7_OP4(0xef80, 0x0e50, 0xef80, 0x0840, T1, VMUL_S), + ARMv7_OP4(0xfe80, 0x0e50, 0xf280, 0x0840, A1, VMUL_S), + ARMv7_OP4(0xef80, 0x0f50, 0xef80, 0x0a40, T2, VMUL_S), + ARMv7_OP4(0xfe80, 0x0f50, 0xf280, 0x0a40, A2, VMUL_S), + + ARMv7_OP4(0xefb8, 0x00b0, 0xef80, 0x0030, T1, VMVN_IMM), + ARMv7_OP4(0xfeb8, 0x00b0, 0xf280, 0x0030, A1, VMVN_IMM), + + ARMv7_OP4(0xffb3, 0x0f90, 0xffb0, 0x0580, T1, VMVN_REG), + ARMv7_OP4(0xffb3, 0x0f90, 0xf3b0, 0x0580, A1, VMVN_REG), + + ARMv7_OP4(0xffb3, 0x0b90, 0xffb1, 0x0380, T1, VNEG), + ARMv7_OP4(0xffb3, 0x0b90, 0xf3b1, 0x0380, A1, VNEG), + ARMv7_OP4(0xffbf, 0x0ed0, 0xeeb1, 0x0a40, T2, VNEG), + ARMv7_OP4(0x0fbf, 0x0ed0, 0x0eb1, 0x0a40, A2, VNEG), + + ARMv7_OP4(0xffb0, 0x0e10, 0xee10, 0x0a00, T1, VNM__), + ARMv7_OP4(0x0fb0, 0x0e10, 0x0e10, 0x0a00, A1, VNM__), + ARMv7_OP4(0xffb0, 0x0e50, 0xee20, 0x0a40, T2, VNM__), + ARMv7_OP4(0x0fb0, 0x0e50, 0x0e20, 0x0a40, A2, VNM__), + + ARMv7_OP4(0xffb0, 0x0f10, 0xef30, 0x0110, T1, VORN_REG), + ARMv7_OP4(0xffb0, 0x0f10, 0xf230, 0x0110, A1, VORN_REG), + + ARMv7_OP4(0xefb8, 0x00b0, 0xef80, 0x0010, T1, VORR_IMM), + ARMv7_OP4(0xfeb8, 0x00b0, 0xf280, 0x0010, A1, VORR_IMM), + + ARMv7_OP4(0xffb0, 0x0f10, 0xef20, 0x0110, T1, VORR_REG), + ARMv7_OP4(0xffb0, 0x0f10, 0xf220, 0x0110, A1, VORR_REG), + + ARMv7_OP4(0xffb3, 0x0f10, 0xffb0, 0x0600, T1, VPADAL), + ARMv7_OP4(0xffb3, 0x0f10, 0xf3b0, 0x0600, A1, VPADAL), + + ARMv7_OP4(0xff80, 0x0f10, 0xef00, 0x0b10, T1, VPADD), + ARMv7_OP4(0xff80, 0x0f10, 0xf200, 0x0b10, A1, VPADD), + + ARMv7_OP4(0xffa0, 0x0f10, 0xff00, 0x0d00, T1, VPADD_FP), + ARMv7_OP4(0xffa0, 0x0f10, 0xf300, 0x0d00, A1, VPADD_FP), + + ARMv7_OP4(0xffb3, 0x0f10, 0xffb0, 0x0200, T1, VPADDL), + ARMv7_OP4(0xffb3, 0x0f10, 0xf3b0, 0x0200, A1, VPADDL), + + ARMv7_OP4(0xef80, 0x0f00, 0xef00, 0x0a00, T1, VPMAXMIN), + ARMv7_OP4(0xfe80, 0x0f00, 0xf200, 0x0a00, A1, VPMAXMIN), + + ARMv7_OP4(0xff80, 0x0f10, 0xff00, 0x0f00, T1, VPMAXMIN_FP), + ARMv7_OP4(0xff80, 0x0f10, 0xf300, 0x0f00, A1, VPMAXMIN_FP), + + ARMv7_OP4(0xffbf, 0x0f00, 0xecbd, 0x0b00, T1, VPOP), + ARMv7_OP4(0x0fbf, 0x0f00, 0x0cbd, 0x0b00, A1, VPOP), + ARMv7_OP4(0xffbf, 0x0f00, 0xecbd, 0x0a00, T2, VPOP), + ARMv7_OP4(0x0fbf, 0x0f00, 0x0cbd, 0x0a00, A2, VPOP), + + ARMv7_OP4(0xffbf, 0x0f00, 0xed2d, 0x0b00, T1, VPUSH), + ARMv7_OP4(0x0fbf, 0x0f00, 0x0d2d, 0x0b00, A1, VPUSH), + ARMv7_OP4(0xffbf, 0x0f00, 0xed2d, 0x0a00, T2, VPUSH), + ARMv7_OP4(0x0fbf, 0x0f00, 0x0d2d, 0x0a00, A2, VPUSH), + + // TODO: VQ* instructions + + ARMv7_OP4(0xff80, 0x0f50, 0xff80, 0x0400, T1, VRADDHN), + ARMv7_OP4(0xff80, 0x0f50, 0xf380, 0x0400, A1, VRADDHN), + + ARMv7_OP4(0xffb3, 0x0e90, 0xffb3, 0x0400, T1, VRECPE), + ARMv7_OP4(0xffb3, 0x0e90, 0xf3b3, 0x0400, A1, VRECPE), + + ARMv7_OP4(0xffa0, 0x0f10, 0xef00, 0x0f10, T1, VRECPS), + ARMv7_OP4(0xffa0, 0x0f10, 0xf200, 0x0f10, A1, VRECPS), + + ARMv7_OP4(0xffb3, 0x0e10, 0xffb0, 0x0000, T1, VREV__), + ARMv7_OP4(0xffb3, 0x0e10, 0xf3b0, 0x0000, A1, VREV__), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0100, T1, VRHADD), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0100, A1, VRHADD), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0500, T1, VRSHL), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0500, A1, VRSHL), + + ARMv7_OP4(0xef80, 0x0f10, 0xef80, 0x0210, T1, VRSHR), + ARMv7_OP4(0xfe80, 0x0f10, 0xf280, 0x0210, A1, VRSHR), + + ARMv7_OP4(0xff80, 0x0fd0, 0xef80, 0x0850, T1, VRSHRN), + ARMv7_OP4(0xff80, 0x0fd0, 0xf280, 0x0850, A1, VRSHRN), + + ARMv7_OP4(0xffb3, 0x0e90, 0xffb3, 0x0480, T1, VRSQRTE), + ARMv7_OP4(0xffb3, 0x0e90, 0xf3b3, 0x0480, A1, VRSQRTE), + + ARMv7_OP4(0xffa0, 0x0f10, 0xef20, 0x0f10, T1, VRSQRTS), + ARMv7_OP4(0xffa0, 0x0f10, 0xf220, 0x0f10, A1, VRSQRTS), + + ARMv7_OP4(0xef80, 0x0f10, 0xef80, 0x0310, T1, VRSRA), + ARMv7_OP4(0xfe80, 0x0f10, 0xf280, 0x0310, A1, VRSRA), + + ARMv7_OP4(0xff80, 0x0f50, 0xff80, 0x0600, T1, VRSUBHN), + ARMv7_OP4(0xff80, 0x0f50, 0xf380, 0x0600, A1, VRSUBHN), + + ARMv7_OP4(0xff80, 0x0f10, 0xef80, 0x0510, T1, VSHL_IMM), + ARMv7_OP4(0xff80, 0x0f10, 0xf280, 0x0510, A1, VSHL_IMM), + + ARMv7_OP4(0xef80, 0x0f10, 0xef00, 0x0400, T1, VSHL_REG), + ARMv7_OP4(0xfe80, 0x0f10, 0xf200, 0x0400, A1, VSHL_REG), + + ARMv7_OP4(0xef80, 0x0fd0, 0xef80, 0x0a10, T1, VSHLL), + ARMv7_OP4(0xfe80, 0x0fd0, 0xf280, 0x0a10, A1, VSHLL), + ARMv7_OP4(0xffb3, 0x0fd0, 0xffb2, 0x0300, T2, VSHLL), + ARMv7_OP4(0xffb3, 0x0fd0, 0xf3b2, 0x0300, A2, VSHLL), + + ARMv7_OP4(0xef80, 0x0f10, 0xef80, 0x0010, T1, VSHR), + ARMv7_OP4(0xfe80, 0x0f10, 0xf280, 0x0010, A1, VSHR), + + ARMv7_OP4(0xff80, 0x0fd0, 0xef80, 0x0810, T1, VSHRN), + ARMv7_OP4(0xff80, 0x0fd0, 0xf280, 0x0810, A1, VSHRN), + + ARMv7_OP4(0xff80, 0x0f10, 0xff80, 0x0510, T1, VSLI), + ARMv7_OP4(0xff80, 0x0f10, 0xf380, 0x0510, A1, VSLI), + + ARMv7_OP4(0xffbf, 0x0ed0, 0xeeb1, 0x0ac0, T1, VSQRT), + ARMv7_OP4(0x0fbf, 0x0ed0, 0x0eb1, 0x0ac0, A1, VSQRT), + + ARMv7_OP4(0xef80, 0x0f10, 0xef80, 0x0110, T1, VSRA), + ARMv7_OP4(0xfe80, 0x0f10, 0xf280, 0x0110, A1, VSRA), + + ARMv7_OP4(0xff80, 0x0f10, 0xff80, 0x0410, T1, VSRI), + ARMv7_OP4(0xff80, 0x0f10, 0xf380, 0x0410, A1, VSRI), + + ARMv7_OP4(0xffb0, 0x0000, 0xf900, 0x0000, T1, VST__MS), // VST1, VST2, VST3, VST4 + ARMv7_OP4(0xffb0, 0x0000, 0xf400, 0x0000, A1, VST__MS), + + ARMv7_OP4(0xffb0, 0x0300, 0xf980, 0x0000, T1, VST1_SL), + ARMv7_OP4(0xffb0, 0x0300, 0xf480, 0x0000, A1, VST1_SL), + + ARMv7_OP4(0xffb0, 0x0300, 0xf980, 0x0100, T1, VST2_SL), + ARMv7_OP4(0xffb0, 0x0300, 0xf480, 0x0100, A1, VST2_SL), + + ARMv7_OP4(0xffb0, 0x0300, 0xf980, 0x0200, T1, VST3_SL), + ARMv7_OP4(0xffb0, 0x0300, 0xf480, 0x0200, A1, VST3_SL), + + ARMv7_OP4(0xffb0, 0x0300, 0xf980, 0x0300, T1, VST4_SL), + ARMv7_OP4(0xffb0, 0x0300, 0xf480, 0x0300, A1, VST4_SL), + + ARMv7_OP4(0xfe10, 0x0f00, 0xec00, 0x0b00, T1, VSTM), + ARMv7_OP4(0x0e10, 0x0f00, 0x0c00, 0x0b00, A1, VSTM), + ARMv7_OP4(0xfe10, 0x0f00, 0xec00, 0x0a00, T2, VSTM), + ARMv7_OP4(0x0e10, 0x0f00, 0x0c00, 0x0a00, A2, VSTM), + + ARMv7_OP4(0xff30, 0x0f00, 0xed00, 0x0b00, T1, VSTR), + ARMv7_OP4(0x0f30, 0x0f00, 0x0d00, 0x0b00, A1, VSTR), + ARMv7_OP4(0xff30, 0x0f00, 0xed00, 0x0a00, T2, VSTR), + ARMv7_OP4(0x0f30, 0x0f00, 0x0d00, 0x0a00, A2, VSTR), + + ARMv7_OP4(0xff80, 0x0f10, 0xff00, 0x0800, T1, VSUB), + ARMv7_OP4(0xff80, 0x0f10, 0xf300, 0x0800, A1, VSUB), + + ARMv7_OP4(0xffa0, 0x0f10, 0xef20, 0x0d00, T1, VSUB_FP), + ARMv7_OP4(0xffa0, 0x0f10, 0xf220, 0x0d00, A1, VSUB_FP), + ARMv7_OP4(0xffb0, 0x0e50, 0xee30, 0x0a40, T2, VSUB_FP), + ARMv7_OP4(0x0fb0, 0x0e50, 0x0e30, 0x0a40, A2, VSUB_FP), + + ARMv7_OP4(0xff80, 0x0f50, 0xef80, 0x0600, T1, VSUBHN), + ARMv7_OP4(0xff80, 0x0f50, 0xf280, 0x0600, A1, VSUBHN), + + ARMv7_OP4(0xef80, 0x0e50, 0xef80, 0x0200, T1, VSUB_), + ARMv7_OP4(0xfe80, 0x0e50, 0xf280, 0x0200, A1, VSUB_), + + ARMv7_OP4(0xffb3, 0x0f90, 0xffb2, 0x0000, T1, VSWP), + ARMv7_OP4(0xffb3, 0x0f90, 0xf3b2, 0x0000, A1, VSWP), + + ARMv7_OP4(0xffb0, 0x0c10, 0xffb0, 0x0800, T1, VTB_), + ARMv7_OP4(0xffb0, 0x0c10, 0xf3b0, 0x0800, A1, VTB_), + + ARMv7_OP4(0xffb3, 0x0f90, 0xffb2, 0x0080, T1, VTRN), + ARMv7_OP4(0xffb3, 0x0f90, 0xf3b2, 0x0080, A1, VTRN), + + ARMv7_OP4(0xff80, 0x0f10, 0xef00, 0x0810, T1, VTST), + ARMv7_OP4(0xff80, 0x0f10, 0xf200, 0x0810, A1, VTST), + + ARMv7_OP4(0xffb3, 0x0f90, 0xffb2, 0x0100, T1, VUZP), + ARMv7_OP4(0xffb3, 0x0f90, 0xf3b2, 0x0100, A1, VUZP), + + ARMv7_OP4(0xffb3, 0x0f90, 0xffb2, 0x0180, T1, VZIP), + ARMv7_OP4(0xffb3, 0x0f90, 0xf3b2, 0x0180, A1, VZIP), + + ARMv7_OP2(0xffff, 0xbf20, T1, WFE), + ARMv7_OP4(0xffff, 0xffff, 0xf3af, 0x8002, T2, WFE), + ARMv7_OP4(0x0fff, 0xffff, 0x0320, 0xf002, A1, WFE), + ARMv7_OP2(0xffff, 0xbf30, T1, WFI), + ARMv7_OP4(0xffff, 0xffff, 0xf3af, 0x8003, T2, WFI), + ARMv7_OP4(0x0fff, 0xffff, 0x0320, 0xf003, A1, WFI), + ARMv7_OP2(0xffff, 0xbf10, T1, YIELD), + ARMv7_OP4(0xffff, 0xffff, 0xf3af, 0x8001, T2, YIELD), + ARMv7_OP4(0x0fff, 0xffff, 0x0320, 0xf001, A1, YIELD), +}; + +#undef ARMv7_OP2 +#undef ARMv7_OP4 +#undef SKIP_IF +#undef BF +#undef BT + +struct ARMv7_op2_table_t +{ + const ARMv7_opcode_t* data[0x10000]; + + ARMv7_op2_table_t() + { + std::vector t2; + + for (auto& opcode : ARMv7_opcode_table) + { + if (opcode.length == 2) + { + if (opcode.code & ~opcode.mask) + { + LOG_ERROR(GENERAL, "%s: wrong opcode mask (mask=0x%04x, code=0x%04x)", opcode.name, opcode.mask >> 16, opcode.code >> 16); + } + + t2.push_back(&opcode); + } + } + + for (u32 i = 0; i < 0x10000; i++) + { + data[i] = nullptr; + + for (auto& opcode : t2) + { + if (((i << 16) & opcode->mask) == opcode->code && (!opcode->skip || !opcode->skip(i))) + { + data[i] = opcode; + break; + } + } + } + } + +} g_op2t; + +struct ARMv7_op4t_table_t +{ + std::vector table; + + ARMv7_op4t_table_t() + { + for (auto& opcode : ARMv7_opcode_table) + { + if (opcode.length == 4 && opcode.type < A1) + { + if (opcode.code & ~opcode.mask) + { + LOG_ERROR(GENERAL, "%s: wrong opcode mask (mask=0x%04x 0x%04x, code=0x%04x 0x%04x)", opcode.name, opcode.mask >> 16, (u16)opcode.mask, opcode.code >> 16, (u16)opcode.code); + } + + table.push_back(&opcode); + } + } + } + +} g_op4t; + +std::unordered_map g_opct; + +void armv7_decoder_initialize(u32 addr, u32 end_addr, bool dump) +{ + // 1. Find every 4-byte thumb instruction and cache it + // 2. If some instruction is not recognized, print the error + // 3. Possibly print disasm + + g_opct.clear(); + + while (addr < end_addr) + { + ARMv7Code code = {}; + code.code0 = vm::psv::read16(addr); + + auto found = g_op2t.data[code.code0]; + + if (!found) + { + code.code1 = code.code0; + code.code0 = vm::psv::read16(addr + 2); + + auto op = g_opct.find(code.data); + if (op != g_opct.end()) + { + found = op->second; + } + } + + if (!found) + { + for (auto opcode : g_op4t.table) + { + if ((code.data & opcode->mask) == opcode->code && (!opcode->skip || !opcode->skip(code.data))) + { + g_opct[code.data] = (found = opcode); + break; + } + } + } + + if (!found) + { + LOG_ERROR(ARMv7, "Unknown instruction found at address 0x%08x: %04x %04x", addr, code.code1, code.code0); + addr += 4; + } + else + { + if (dump) if (found->length == 2) + { + LOG_NOTICE(ARMv7, "0x%08x: %04x %s", addr, code.code0, found->name); + } + else + { + LOG_NOTICE(ARMv7, "0x%08x: %04x %04x %s", addr, code.code1, code.code0, found->name); + } + + if (found->func == ARMv7_instrs::BLX && found->type == T2) + { + const u32 s = (code.data >> 26) & 0x1; + const u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; + const u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; + const u32 target = (addr + 4 & ~3) + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + + // possibly a call to imported function: + if (target >= end_addr && ((target - end_addr) % 16) == 0 && vm::psv::read16(target) == 0xf870) + { + const u32 instr = vm::psv::read32(target); + + // check if not "unimplemented" + if (instr >> 16) + { + // replace BLX with "hack" instruction directly, it can help to see where it was called from + vm::psv::write32(addr, instr); + } + } + else + { + LOG_ERROR(ARMv7, "Unrecognized BLX call found at adddress 0x%08x (target=0x%08x)", addr, target); + } + } + + addr += found->length; + } + } + + while (vm::psv::read16(addr) == 0xf870) + { + g_opct[0xf8700000 | vm::psv::read16(addr + 2)] = g_op4t.table[0]; + addr += 16; + } + + LOG_NOTICE(ARMv7, "armv7_decoder_initialize() finished, g_opct.size() = %lld", g_opct.size()); +} + +u32 ARMv7Decoder::DecodeMemory(const u32 address) +{ + if (address & 0x1) + { + throw "ARMv7Decoder::DecodeMemory() failed (something is wrong with instruction set)"; + } + + ARMv7Code code = {}; + code.code0 = vm::psv::read16(address); + + if (auto opcode = g_op2t.data[code.code0]) + { + (*opcode->func)(m_ctx, code, opcode->type); + return 2; + } + + code.code1 = code.code0; + code.code0 = vm::psv::read16(address + 2); + + auto op = g_opct.find(code.data); + if (op != g_opct.end()) + { + (*op->second->func)(m_ctx, code, op->second->type); + return 4; + } + + //for (auto opcode : g_op4t.table) + //{ + // if ((code.data & opcode->mask) == opcode->code && (!opcode->skip || !opcode->skip(code.data))) + // { + // (*opcode->func)(m_ctx, code, opcode->type); + // return 4; + // } + //} + + ARMv7_instrs::UNK(m_ctx, code); + return 4; + + // "group" decoding algorithm (temporarily disabled) + + //execute_main_group(&m_thr); + //// LOG_NOTICE(GENERAL, "%s, %d \n\n", m_thr.m_last_instr_name, m_thr.m_last_instr_size); + //m_thr.m_last_instr_name = "Unknown"; + //return m_thr.m_last_instr_size; +} diff --git a/rpcs3/Emu/ARMv7/ARMv7Decoder.h b/rpcs3/Emu/ARMv7/ARMv7Decoder.h index 2a7de502f6..229f74014b 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Decoder.h +++ b/rpcs3/Emu/ARMv7/ARMv7Decoder.h @@ -1,48 +1,18 @@ #pragma once - #include "Emu/CPU/CPUDecoder.h" -#include "ARMv7Thread.h" -#include "ARMv7Interpreter.h" -#include "ARMv7Opcodes.h" -#include "Utilities/Log.h" + +struct ARMv7Context; class ARMv7Decoder : public CPUDecoder { - ARMv7Thread& m_thr; + ARMv7Context& m_ctx; public: - ARMv7Decoder(ARMv7Thread& thr) : m_thr(thr) + ARMv7Decoder(ARMv7Context& context) : m_ctx(context) { } - virtual u8 DecodeMemory(const u32 address) - { - m_thr.update_code(address & ~1); + virtual u32 DecodeMemory(const u32 address); +}; - // LOG_NOTICE(GENERAL, "code0 = 0x%04x, code1 = 0x%04x, data = 0x%08x", m_thr.code.code0, m_thr.code.code1, m_thr.code.data); - // LOG_NOTICE(GENERAL, "arg = 0x%08x", m_thr.m_arg); - // Emu.Pause(); - - // old decoding algorithm - /* - for (auto& opcode : ARMv7_opcode_table) - { - if ((opcode.type < A1) == ((address & 0x1) == 0) && (m_thr.m_arg & opcode.mask) == opcode.code) - { - m_thr.code.data = opcode.length == 2 ? m_thr.code.code0 : m_thr.m_arg; - (*opcode.func)(&m_thr, opcode.type); - // LOG_NOTICE(GENERAL, "%s, %d \n\n", opcode.name, opcode.length); - return opcode.length; - } - } - - ARMv7_instrs::UNK(&m_thr); - return address & 0x1 ? 4 : 2; - */ - - execute_main_group(&m_thr); - // LOG_NOTICE(GENERAL, "%s, %d \n\n", m_thr.m_last_instr_name, m_thr.m_last_instr_size); - m_thr.m_last_instr_name = "Unknown"; - return m_thr.m_last_instr_size; - } -}; \ No newline at end of file +void armv7_decoder_initialize(u32 addr, u32 end_addr, bool dump = false); diff --git a/rpcs3/Emu/ARMv7/ARMv7DisAsm.cpp b/rpcs3/Emu/ARMv7/ARMv7DisAsm.cpp index ccb2582cad..6a3626522b 100644 --- a/rpcs3/Emu/ARMv7/ARMv7DisAsm.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7DisAsm.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#if 0 #include "ARMv7DisAsm.h" void ARMv7DisAsm::UNK(const u32 data) @@ -1119,4 +1120,4 @@ void ARMv7DisAsm::UXTH(const u32 data, const ARMv7_encoding type) { Write(__FUNCTION__); } - +#endif diff --git a/rpcs3/Emu/ARMv7/ARMv7DisAsm.h b/rpcs3/Emu/ARMv7/ARMv7DisAsm.h index 05375dc167..848baaf7cb 100644 --- a/rpcs3/Emu/ARMv7/ARMv7DisAsm.h +++ b/rpcs3/Emu/ARMv7/ARMv7DisAsm.h @@ -1,5 +1,4 @@ #pragma once -#include "Emu/ARMv7/ARMv7Opcodes.h" #include "Emu/CPU/CPUDisAsm.h" static const char* g_arm_cond_name[16] = @@ -10,6 +9,14 @@ static const char* g_arm_cond_name[16] = "gt", "le", "al", "al", }; +static const char* g_arm_reg_name[16] = +{ + "r0", "r1", "r2", "r3", + "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", + "r12", "sp", "lr", "pc", +}; + class ARMv7DisAsm : public CPUDisAsm { @@ -24,6 +31,7 @@ protected: return (u32)dump_pc + imm; } +#if 0 std::string GetRegsListString(u16 regs_list) { std::string regs_str; @@ -316,4 +324,5 @@ protected: virtual void UXTB(const u32 data, const ARMv7_encoding type); virtual void UXTB16(const u32 data, const ARMv7_encoding type); virtual void UXTH(const u32 data, const ARMv7_encoding type); +#endif }; diff --git a/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp b/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp index aa963e583b..c6292e371a 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Interpreter.cpp @@ -1,7 +1,9 @@ #include "stdafx.h" +#include "Utilities/Log.h" #include "Emu/System.h" #include "Emu/Memory/Memory.h" #include "Emu/CPU/CPUDecoder.h" + #include "ARMv7Thread.h" #include "PSVFuncList.h" #include "ARMv7Interpreter.h" @@ -101,7 +103,7 @@ u32 ARMv7_instrs::LSL_C(u32 x, s32 shift, bool& carry_out) return shift < 32 ? x << shift : 0; } -u32 ARMv7_instrs::LSL(u32 x, s32 shift) +u32 ARMv7_instrs::LSL_(u32 x, s32 shift) { assert(shift >= 0); return shift < 32 ? x << shift : 0; @@ -114,7 +116,7 @@ u32 ARMv7_instrs::LSR_C(u32 x, s32 shift, bool& carry_out) return shift < 32 ? x >> shift : 0; } -u32 ARMv7_instrs::LSR(u32 x, s32 shift) +u32 ARMv7_instrs::LSR_(u32 x, s32 shift) { assert(shift >= 0); return shift < 32 ? x >> shift : 0; @@ -127,7 +129,7 @@ s32 ARMv7_instrs::ASR_C(s32 x, s32 shift, bool& carry_out) return shift < 32 ? x >> shift : x >> 31; } -s32 ARMv7_instrs::ASR(s32 x, s32 shift) +s32 ARMv7_instrs::ASR_(s32 x, s32 shift) { assert(shift >= 0); return shift < 32 ? x >> shift : x >> 31; @@ -140,7 +142,7 @@ u32 ARMv7_instrs::ROR_C(u32 x, s32 shift, bool& carry_out) return x >> shift | x << (32 - shift); } -u32 ARMv7_instrs::ROR(u32 x, s32 shift) +u32 ARMv7_instrs::ROR_(u32 x, s32 shift) { return x >> shift | x << (32 - shift); } @@ -151,7 +153,7 @@ u32 ARMv7_instrs::RRX_C(u32 x, bool carry_in, bool& carry_out) return ((u32)carry_in << 31) | (x >> 1); } -u32 ARMv7_instrs::RRX(u32 x, bool carry_in) +u32 ARMv7_instrs::RRX_(u32 x, bool carry_in) { return ((u32)carry_in << 31) | (x >> 1); } @@ -222,25 +224,25 @@ u32 ARMv7_instrs::ThumbExpandImm_C(u32 imm12, bool carry_in, bool& carry_out) } } -u32 ARMv7_instrs::ThumbExpandImm(ARMv7Thread* CPU, u32 imm12) +u32 ARMv7_instrs::ThumbExpandImm(ARMv7Context& context, u32 imm12) { - bool carry = CPU->APSR.C; + bool carry = context.APSR.C; return ThumbExpandImm_C(imm12, carry, carry); } -bool ARMv7_instrs::ConditionPassed(ARMv7Thread* CPU, u32 cond) +bool ARMv7_instrs::ConditionPassed(ARMv7Context& context, u32 cond) { bool result = false; switch (cond >> 1) { - case 0: result = CPU->APSR.Z == 1; break; - case 1: result = CPU->APSR.C == 1; break; - case 2: result = CPU->APSR.N == 1; break; - case 3: result = CPU->APSR.V == 1; break; - case 4: result = CPU->APSR.C == 1 && CPU->APSR.Z == 0; break; - case 5: result = CPU->APSR.N == CPU->APSR.V; break; - case 6: result = CPU->APSR.N == CPU->APSR.V && CPU->APSR.Z == 0; break; + case 0: result = context.APSR.Z == 1; break; + case 1: result = context.APSR.C == 1; break; + case 2: result = context.APSR.N == 1; break; + case 3: result = context.APSR.V == 1; break; + case 4: result = context.APSR.C == 1 && context.APSR.Z == 0; break; + case 5: result = context.APSR.N == context.APSR.V; break; + case 6: result = context.APSR.N == context.APSR.V && context.APSR.Z == 0; break; case 7: return true; } @@ -253,46 +255,92 @@ bool ARMv7_instrs::ConditionPassed(ARMv7Thread* CPU, u32 cond) } // instructions -void ARMv7_instrs::UNK(ARMv7Thread* thr) +void ARMv7_instrs::UNK(ARMv7Context& context, const ARMv7Code code) { - LOG_ERROR(HLE, "Unknown/illegal opcode! (0x%04x : 0x%04x)", thr->code.data >> 16, thr->code.data & 0xffff); - Emu.Pause(); + throw fmt::format("Unknown/illegal opcode: 0x%04x 0x%04x", code.code1, code.code0); } -void ARMv7_instrs::NULL_OP(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::NULL_OP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - LOG_ERROR(HLE, "Null opcode found: data = 0x%x", thr->m_arg); - Emu.Pause(); + throw fmt::format("Null opcode found: 0x%04x 0x%04x", code.code1, code.code0); } -void ARMv7_instrs::HACK(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::HACK(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); - u32 code = 0; + u32 cond = context.ITSTATE.advance(); + u32 func = 0; switch (type) { case T1: { - code = thr->code.data & 0xffff; + func = code.data & 0xffff; break; } case A1: { - cond = thr->code.data >> 28; - code = (thr->code.data & 0xfff00) >> 4 | (thr->code.data & 0xf); + cond = code.data >> 28; + func = (code.data & 0xfff00) >> 4 | (code.data & 0xf); break; } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - execute_psv_func_by_index(*thr, code); + execute_psv_func_by_index(context, func); } } -void ARMv7_instrs::ADC_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MRC_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + u32 cond = context.ITSTATE.advance(); + u32 t = 0; + u32 cp = 0; + u32 opc1 = 0; + u32 opc2 = 0; + u32 cn = 0; + u32 cm = 0; + + switch (type) + { + case T1: + case A1: + { + t = (code.data & 0xf000) >> 12; + cp = (code.data & 0xf00) >> 8; + opc1 = (code.data & 0xe00000) >> 21; + opc2 = (code.data & 0xe0) >> 5; + cn = (code.data & 0xf0000) >> 16; + cm = (code.data & 0xf); + + if (cp - 10 < 2) + { + throw "MRC_(T1/A1): Advanced SIMD and VFP"; + } + break; + } + default: throw __FUNCTION__; + } + + if (ConditionPassed(context, cond)) + { + if (cp == 15 && opc1 == 0 && cn == 13 && cm == 0 && opc2 == 3) + { + LOG_ERROR(ARMv7, "TODO: TLS requested"); + + if (t < 15) + { + context.GPR[t] = 0; + return; + } + } + + throw fmt::format("Bad instruction: mrc p%d,%d,r%d,c%d,c%d,%d", cp, opc1, t, cn, cm, opc2); + } +} + +void ARMv7_instrs::ADC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -301,7 +349,7 @@ void ARMv7_instrs::ADC_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::ADC_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ADC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -310,7 +358,7 @@ void ARMv7_instrs::ADC_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::ADC_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ADC_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -320,10 +368,10 @@ void ARMv7_instrs::ADC_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::ADD_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ADD_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - bool set_flags = !thr->ITSTATE; - u32 cond = thr->ITSTATE.advance(); + bool set_flags = !context.ITSTATE; + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 n = 0; u32 imm32 = 0; @@ -332,48 +380,48 @@ void ARMv7_instrs::ADD_IMM(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data & 0x7); - n = (thr->code.data & 0x38) >> 3; - imm32 = (thr->code.data & 0x1c0) >> 6; + d = (code.data & 0x7); + n = (code.data & 0x38) >> 3; + imm32 = (code.data & 0x1c0) >> 6; break; } case T2: { - d = n = (thr->code.data & 0x700) >> 8; - imm32 = (thr->code.data & 0xff); + d = n = (code.data & 0x700) >> 8; + imm32 = (code.data & 0xff); break; } case T3: { - d = (thr->code.data & 0xf00) >> 8; - n = (thr->code.data & 0xf0000) >> 16; - set_flags = (thr->code.data & 0x100000); - imm32 = ThumbExpandImm(thr, (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff)); + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; + set_flags = (code.data & 0x100000); + imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); if (d == 15 && set_flags) { - throw "CMN (immediate)"; + throw "ADD_IMM_T3: CMN (immediate)"; } if (n == 13) { - throw "ADD (SP plus immediate)"; + throw "ADD_IMM_T3: ADD (SP plus immediate)"; } break; } case T4: { - d = (thr->code.data & 0xf00) >> 8; - n = (thr->code.data & 0xf0000) >> 16; + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; set_flags = false; - imm32 = (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff); + imm32 = (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); if (n == 15) { - throw "ADR"; + throw "ADD_IMM_T4: ADR"; } if (n == 13) { - throw "ADD (SP plus immediate)"; + throw "ADD_IMM_T4: ADD (SP plus immediate)"; } break; } @@ -381,29 +429,29 @@ void ARMv7_instrs::ADD_IMM(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { if (set_flags) { bool carry, overflow; - const u32 res = AddWithCarry(thr->read_gpr(n), imm32, false, carry, overflow); - thr->write_gpr(d, res); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 res = AddWithCarry(context.read_gpr(n), imm32, false, carry, overflow); + context.write_gpr(d, res); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } else { - thr->write_gpr(d, thr->read_gpr(n) + imm32); + context.write_gpr(d, context.read_gpr(n) + imm32); } } } -void ARMv7_instrs::ADD_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ADD_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - bool set_flags = !thr->ITSTATE; - u32 cond = thr->ITSTATE.advance(); + bool set_flags = !context.ITSTATE; + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 n = 0; u32 m = 0; @@ -414,38 +462,38 @@ void ARMv7_instrs::ADD_REG(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data & 0x7); - n = (thr->code.data & 0x38) >> 3; - m = (thr->code.data & 0x1c0) >> 6; + d = (code.data & 0x7); + n = (code.data & 0x38) >> 3; + m = (code.data & 0x1c0) >> 6; break; } case T2: { - n = d = (thr->code.data & 0x80) >> 4 | (thr->code.data & 0x7); - m = (thr->code.data & 0x78) >> 3; + n = d = (code.data & 0x80) >> 4 | (code.data & 0x7); + m = (code.data & 0x78) >> 3; set_flags = false; if (n == 13 || m == 13) { - throw "ADD (SP plus register)"; + throw "ADD_REG_T2: ADD (SP plus register)"; } break; } case T3: { - d = (thr->code.data & 0xf00) >> 8; - n = (thr->code.data & 0xf0000) >> 16; - m = (thr->code.data & 0xf); - set_flags = (thr->code.data & 0x100000); - shift_t = DecodeImmShift((thr->code.data & 0x30) >> 4, (thr->code.data & 0x7000) >> 10 | (thr->code.data & 0xc0) >> 6, &shift_n); + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; + m = (code.data & 0xf); + set_flags = (code.data & 0x100000); + shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); if (d == 15 && set_flags) { - throw "CMN (register)"; + throw "ADD_REG_T3: CMN (register)"; } if (n == 13) { - throw "ADD (SP plus register)"; + throw "ADD_REG_T3: ADD (SP plus register)"; } break; } @@ -453,27 +501,27 @@ void ARMv7_instrs::ADD_REG(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - const u32 shifted = Shift(thr->read_gpr(m), shift_t, shift_n, true); + const u32 shifted = Shift(context.read_gpr(m), shift_t, shift_n, true); if (set_flags) { bool carry, overflow; - const u32 res = AddWithCarry(thr->read_gpr(n), shifted, false, carry, overflow); - thr->write_gpr(d, res); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 res = AddWithCarry(context.read_gpr(n), shifted, false, carry, overflow); + context.write_gpr(d, res); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } else { - thr->write_gpr(d, thr->read_gpr(n) + shifted); + context.write_gpr(d, context.read_gpr(n) + shifted); } } } -void ARMv7_instrs::ADD_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ADD_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -482,9 +530,9 @@ void ARMv7_instrs::ADD_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::ADD_SPI(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ADD_SPI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 d = 13; bool set_flags = false; u32 imm32 = 0; @@ -493,60 +541,60 @@ void ARMv7_instrs::ADD_SPI(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data & 0x700) >> 8; - imm32 = (thr->code.data & 0xff) << 2; + d = (code.data & 0x700) >> 8; + imm32 = (code.data & 0xff) << 2; break; } case T2: { - imm32 = (thr->code.data & 0x7f) << 2; + imm32 = (code.data & 0x7f) << 2; break; } case T3: { - d = (thr->code.data & 0xf00) >> 8; - set_flags = (thr->code.data & 0x100000); - imm32 = ThumbExpandImm(thr, (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff)); + d = (code.data & 0xf00) >> 8; + set_flags = (code.data & 0x100000); + imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); if (d == 15 && set_flags) { - throw "CMN (immediate)"; + throw "ADD_SPI_T3: CMN (immediate)"; } break; } case T4: { - d = (thr->code.data & 0xf00) >> 8; + d = (code.data & 0xf00) >> 8; set_flags = false; - imm32 = (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff); + imm32 = (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); break; } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { if (set_flags) { bool carry, overflow; - const u32 res = AddWithCarry(thr->SP, imm32, false, carry, overflow); - thr->write_gpr(d, res); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 res = AddWithCarry(context.SP, imm32, false, carry, overflow); + context.write_gpr(d, res); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } else { - thr->write_gpr(d, thr->SP + imm32); + context.write_gpr(d, context.SP + imm32); } } } -void ARMv7_instrs::ADD_SPR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ADD_SPR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 d = 13; u32 m = 0; bool set_flags = false; @@ -557,12 +605,12 @@ void ARMv7_instrs::ADD_SPR(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - m = d = (thr->code.data & 0x80) >> 4 | (thr->code.data & 0x7); + m = d = (code.data & 0x80) >> 4 | (code.data & 0x7); break; } case T2: { - m = (thr->code.data & 0x78) >> 3; + m = (code.data & 0x78) >> 3; if (m == 13) { @@ -572,38 +620,38 @@ void ARMv7_instrs::ADD_SPR(ARMv7Thread* thr, const ARMv7_encoding type) } case T3: { - d = (thr->code.data & 0xf00) >> 8; - m = (thr->code.data & 0xf); - set_flags = (thr->code.data & 0x100000); - shift_t = DecodeImmShift((thr->code.data & 0x30) >> 4, (thr->code.data & 0x7000) >> 10 | (thr->code.data & 0xc0) >> 6, &shift_n); + d = (code.data & 0xf00) >> 8; + m = (code.data & 0xf); + set_flags = (code.data & 0x100000); + shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); break; } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - const u32 shifted = Shift(thr->read_gpr(m), shift_t, shift_n, thr->APSR.C); + const u32 shifted = Shift(context.read_gpr(m), shift_t, shift_n, context.APSR.C); if (set_flags) { bool carry, overflow; - const u32 res = AddWithCarry(thr->SP, shifted, false, carry, overflow); - thr->write_gpr(d, res); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 res = AddWithCarry(context.SP, shifted, false, carry, overflow); + context.write_gpr(d, res); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } else { - thr->write_gpr(d, thr->SP + thr->read_gpr(m)); + context.write_gpr(d, context.SP + context.read_gpr(m)); } } } -void ARMv7_instrs::ADR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ADR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -613,7 +661,7 @@ void ARMv7_instrs::ADR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::AND_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::AND_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -622,7 +670,7 @@ void ARMv7_instrs::AND_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::AND_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::AND_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -631,7 +679,7 @@ void ARMv7_instrs::AND_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::AND_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::AND_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -641,7 +689,7 @@ void ARMv7_instrs::AND_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::ASR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ASR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -650,7 +698,7 @@ void ARMv7_instrs::ASR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::ASR_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ASR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -660,68 +708,68 @@ void ARMv7_instrs::ASR_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::B(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::B(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 jump = 0; // jump = instr_size + imm32 ??? switch (type) { case T1: { - cond = (thr->code.data >> 8) & 0xf; + cond = (code.data >> 8) & 0xf; if (cond == 0xf) { - throw "SVC"; + throw "B_T1: SVC"; } - jump = 4 + sign<9, u32>((thr->code.data & 0xff) << 1); + jump = 4 + sign<9, u32>((code.data & 0xff) << 1); break; } case T2: { - jump = 4 + sign<12, u32>((thr->code.data & 0x7ff) << 1); + jump = 4 + sign<12, u32>((code.data & 0x7ff) << 1); break; } case T3: { - cond = (thr->code.data >> 6) & 0xf; + cond = (code.data >> 22) & 0xf; if (cond >= 0xe) { throw "B_T3: Related encodings"; } - u32 s = (thr->code.data >> 26) & 0x1; - u32 j1 = (thr->code.data >> 13) & 0x1; - u32 j2 = (thr->code.data >> 11) & 0x1; - jump = 4 + sign<21, u32>(s << 20 | j2 << 19 | j1 << 18 | (thr->code.data & 0x3f0000) >> 4 | (thr->code.data & 0x7ff) << 1); + u32 s = (code.data >> 26) & 0x1; + u32 j1 = (code.data >> 13) & 0x1; + u32 j2 = (code.data >> 11) & 0x1; + jump = 4 + sign<21, u32>(s << 20 | j2 << 19 | j1 << 18 | (code.data & 0x3f0000) >> 4 | (code.data & 0x7ff) << 1); break; } case T4: { - u32 s = (thr->code.data >> 26) & 0x1; - u32 i1 = (thr->code.data >> 13) & 0x1 ^ s ^ 1; - u32 i2 = (thr->code.data >> 11) & 0x1 ^ s ^ 1; - jump = 4 + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (thr->code.data & 0x3ff0000) >> 4 | (thr->code.data & 0x7ff) << 1); + u32 s = (code.data >> 26) & 0x1; + u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; + u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; + jump = 4 + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); break; } case A1: { - cond = thr->code.data >> 28; - jump = 1 + 4 + sign<26, u32>((thr->code.data & 0xffffff) << 2); + cond = code.data >> 28; + jump = 1 + 4 + sign<26, u32>((code.data & 0xffffff) << 2); break; } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - thr->SetBranch(thr->PC + jump); + context.thread.SetBranch(context.thread.PC + jump); } } -void ARMv7_instrs::BFC(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BFC(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -730,7 +778,7 @@ void ARMv7_instrs::BFC(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::BFI(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BFI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -740,7 +788,7 @@ void ARMv7_instrs::BFI(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::BIC_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BIC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -749,7 +797,7 @@ void ARMv7_instrs::BIC_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::BIC_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BIC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -758,7 +806,7 @@ void ARMv7_instrs::BIC_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::BIC_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BIC_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -768,7 +816,7 @@ void ARMv7_instrs::BIC_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::BKPT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BKPT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -778,132 +826,132 @@ void ARMv7_instrs::BKPT(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::BL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); - u32 newLR = thr->PC; + u32 cond = context.ITSTATE.advance(); + u32 newLR = context.thread.PC; u32 imm32 = 0; switch (type) { case T1: { - u32 s = (thr->code.data >> 26) & 0x1; - u32 i1 = (thr->code.data >> 13) & 0x1 ^ s ^ 1; - u32 i2 = (thr->code.data >> 11) & 0x1 ^ s ^ 1; - imm32 = 4 + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (thr->code.data & 0x3ff0000) >> 4 | (thr->code.data & 0x7ff) << 1); - newLR = (thr->PC + 4) | 1; + u32 s = (code.data >> 26) & 0x1; + u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; + u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; + imm32 = 4 + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + newLR = (context.thread.PC + 4) | 1; break; } case A1: { - cond = thr->code.data >> 28; - imm32 = 4 + sign<26, u32>((thr->code.data & 0xffffff) << 2); - newLR = (thr->PC + 4) - 4; + cond = code.data >> 28; + imm32 = 4 + sign<26, u32>((code.data & 0xffffff) << 2); + newLR = (context.thread.PC + 4) - 4; break; } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - thr->LR = newLR; - thr->SetBranch(thr->PC + imm32); + context.LR = newLR; + context.thread.SetBranch(context.thread.PC + imm32); } } -void ARMv7_instrs::BLX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BLX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); - u32 newLR = thr->PC; + u32 cond = context.ITSTATE.advance(); + u32 newLR = context.thread.PC; u32 target = 0; switch (type) { case T1: { - target = thr->read_gpr((thr->code.data >> 3) & 0xf); - newLR = (thr->PC + 2) | 1; // ??? + target = context.read_gpr((code.data >> 3) & 0xf); + newLR = (context.thread.PC + 2) | 1; // ??? break; } case T2: { - u32 s = (thr->code.data >> 26) & 0x1; - u32 i1 = (thr->code.data >> 13) & 0x1 ^ s ^ 1; - u32 i2 = (thr->code.data >> 11) & 0x1 ^ s ^ 1; - target = (thr->PC + 4 & ~3) + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (thr->code.data & 0x3ff0000) >> 4 | (thr->code.data & 0x7ff) << 1); - newLR = (thr->PC + 4) | 1; + u32 s = (code.data >> 26) & 0x1; + u32 i1 = (code.data >> 13) & 0x1 ^ s ^ 1; + u32 i2 = (code.data >> 11) & 0x1 ^ s ^ 1; + target = (context.thread.PC + 4 & ~3) + sign<25, u32>(s << 24 | i2 << 23 | i1 << 22 | (code.data & 0x3ff0000) >> 4 | (code.data & 0x7ff) << 1); + newLR = (context.thread.PC + 4) | 1; break; } case A1: { - cond = thr->code.data >> 28; - target = thr->read_gpr(thr->code.data & 0xf); - newLR = (thr->PC + 4) - 4; + cond = code.data >> 28; + target = context.read_gpr(code.data & 0xf); + newLR = (context.thread.PC + 4) - 4; break; } case A2: { - target = (thr->PC + 4 | 1) + sign<25, u32>((thr->code.data & 0xffffff) << 2 | (thr->code.data & 0x1000000) >> 23); - newLR = (thr->PC + 4) - 4; + target = (context.thread.PC + 4 | 1) + sign<25, u32>((code.data & 0xffffff) << 2 | (code.data & 0x1000000) >> 23); + newLR = (context.thread.PC + 4) - 4; break; } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - thr->LR = newLR; + context.LR = newLR; if (target & 1) { - thr->ISET = Thumb; - thr->SetBranch(target & ~1); + context.ISET = Thumb; + context.thread.SetBranch(target & ~1); } else { - thr->ISET = ARM; - thr->SetBranch(target); + context.ISET = ARM; + context.thread.SetBranch(target); } } } -void ARMv7_instrs::BX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::BX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 target = 0; switch (type) { case T1: { - target = thr->read_gpr((thr->code.data >> 3) & 0xf); + target = context.read_gpr((code.data >> 3) & 0xf); break; } case A1: { - cond = thr->code.data >> 28; - target = thr->read_gpr(thr->code.data & 0xf); + cond = code.data >> 28; + target = context.read_gpr(code.data & 0xf); } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { if (target & 1) { - thr->ISET = Thumb; - thr->SetBranch(target & ~1); + context.ISET = Thumb; + context.thread.SetBranch(target & ~1); } else { - thr->ISET = ARM; - thr->SetBranch(target); + context.ISET = ARM; + context.thread.SetBranch(target); } } } -void ARMv7_instrs::CB_Z(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::CB_Z(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -911,14 +959,14 @@ void ARMv7_instrs::CB_Z(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if ((thr->read_gpr(thr->code.data & 0x7) == 0) ^ ((thr->code.data & 0x800) != 0)) + if ((context.read_gpr(code.data & 0x7) == 0) ^ ((code.data & 0x800) != 0)) { - thr->SetBranch(thr->PC + 2 + ((thr->code.data & 0xf8) >> 2) + ((thr->code.data & 0x200) >> 3)); + context.thread.SetBranch(context.thread.PC + 2 + ((code.data & 0xf8) >> 2) + ((code.data & 0x200) >> 3)); } } -void ARMv7_instrs::CLZ(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::CLZ(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -928,7 +976,7 @@ void ARMv7_instrs::CLZ(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::CMN_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::CMN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -937,7 +985,7 @@ void ARMv7_instrs::CMN_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::CMN_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::CMN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -946,7 +994,7 @@ void ARMv7_instrs::CMN_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::CMN_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::CMN_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -956,9 +1004,9 @@ void ARMv7_instrs::CMN_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::CMP_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::CMP_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 n = 0; u32 imm32 = 0; @@ -966,34 +1014,34 @@ void ARMv7_instrs::CMP_IMM(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - n = (thr->code.data & 0x700) >> 8; - imm32 = (thr->code.data & 0xff); + n = (code.data & 0x700) >> 8; + imm32 = (code.data & 0xff); break; } case T2: { - n = (thr->code.data & 0xf0000) >> 16; - imm32 = ThumbExpandImm(thr, (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff)); + n = (code.data & 0xf0000) >> 16; + imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); break; } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { bool carry, overflow; - const u32 res = AddWithCarry(thr->read_gpr(n), ~imm32, true, carry, overflow); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 res = AddWithCarry(context.read_gpr(n), ~imm32, true, carry, overflow); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } } -void ARMv7_instrs::CMP_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::CMP_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 n = 0; u32 m = 0; auto shift_t = SRType_LSL; @@ -1003,40 +1051,40 @@ void ARMv7_instrs::CMP_REG(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - n = (thr->code.data & 0x7); - m = (thr->code.data & 0x38) >> 3; + n = (code.data & 0x7); + m = (code.data & 0x38) >> 3; break; } case T2: { - n = (thr->code.data & 0x80) >> 4 | (thr->code.data & 0x7); - m = (thr->code.data & 0x78) >> 3; + n = (code.data & 0x80) >> 4 | (code.data & 0x7); + m = (code.data & 0x78) >> 3; break; } case T3: { - n = (thr->code.data & 0xf0000) >> 16; - m = (thr->code.data & 0xf); - shift_t = DecodeImmShift((thr->code.data & 0x30) >> 4, (thr->code.data & 0x7000) >> 10 | (thr->code.data & 0xc0) >> 6, &shift_n); + n = (code.data & 0xf0000) >> 16; + m = (code.data & 0xf); + shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); break; } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { bool carry, overflow; - const u32 shifted = Shift(thr->read_gpr(m), shift_t, shift_n, true); - const u32 res = AddWithCarry(thr->read_gpr(n), ~shifted, true, carry, overflow); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 shifted = Shift(context.read_gpr(m), shift_t, shift_n, true); + const u32 res = AddWithCarry(context.read_gpr(n), ~shifted, true, carry, overflow); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } } -void ARMv7_instrs::CMP_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::CMP_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1046,7 +1094,7 @@ void ARMv7_instrs::CMP_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::EOR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::EOR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1055,7 +1103,7 @@ void ARMv7_instrs::EOR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::EOR_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::EOR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1064,7 +1112,7 @@ void ARMv7_instrs::EOR_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::EOR_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::EOR_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1074,18 +1122,18 @@ void ARMv7_instrs::EOR_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::IT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::IT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { case T1: { - if ((thr->code.data & 0xf) == 0) + if ((code.data & 0xf) == 0) { throw "IT_T1: Related encodings"; } - thr->ITSTATE.IT = thr->code.data & 0xff; + context.ITSTATE.IT = code.data & 0xff; return; } default: throw __FUNCTION__; @@ -1093,7 +1141,7 @@ void ARMv7_instrs::IT(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::LDM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1102,7 +1150,7 @@ void ARMv7_instrs::LDM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDMDA(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDMDA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1111,7 +1159,7 @@ void ARMv7_instrs::LDMDA(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDMDB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDMDB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1120,7 +1168,7 @@ void ARMv7_instrs::LDMDB(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDMIB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDMIB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1130,9 +1178,9 @@ void ARMv7_instrs::LDMIB(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::LDR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 t = 0; u32 n = 13; u32 imm32 = 0; @@ -1144,49 +1192,49 @@ void ARMv7_instrs::LDR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - t = (thr->code.data & 0x7); - n = (thr->code.data & 0x38) >> 3; - imm32 = (thr->code.data & 0x7c0) >> 4; + t = (code.data & 0x7); + n = (code.data & 0x38) >> 3; + imm32 = (code.data & 0x7c0) >> 4; break; } case T2: { - t = (thr->code.data & 0x700) >> 8; - imm32 = (thr->code.data & 0xff) << 2; + t = (code.data & 0x700) >> 8; + imm32 = (code.data & 0xff) << 2; break; } case T3: { - t = (thr->code.data & 0xf000) >> 12; - n = (thr->code.data & 0xf0000) >> 16; - imm32 = (thr->code.data & 0xfff); + t = (code.data & 0xf000) >> 12; + n = (code.data & 0xf0000) >> 16; + imm32 = (code.data & 0xfff); if (n == 15) { - throw "LDR (literal)"; + throw "LDR_IMM_T3: LDR (literal)"; } break; } case T4: { - t = (thr->code.data & 0xf000) >> 12; - n = (thr->code.data & 0xf0000) >> 16; - imm32 = (thr->code.data & 0xff); - index = (thr->code.data & 0x400); - add = (thr->code.data & 0x200); - wback = (thr->code.data & 0x100); + t = (code.data & 0xf000) >> 12; + n = (code.data & 0xf0000) >> 16; + imm32 = (code.data & 0xff); + index = (code.data & 0x400); + add = (code.data & 0x200); + wback = (code.data & 0x100); if (n == 15) { - throw "LDR (literal)"; + throw "LDR_IMM_T4: LDR (literal)"; } if (index && add && !wback) { - throw "LDRT"; + throw "LDR_IMM_T4: LDRT"; } if (n == 13 && !index && add && wback && imm32 == 4) { - throw "POP"; + throw "LDR_IMM_T4: POP"; } if (!index && !wback) { @@ -1197,21 +1245,85 @@ void ARMv7_instrs::LDR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - const u32 offset_addr = add ? thr->read_gpr(n) + imm32 : thr->read_gpr(n) - imm32; - const u32 addr = index ? offset_addr : thr->read_gpr(n); + const u32 offset_addr = add ? context.read_gpr(n) + imm32 : context.read_gpr(n) - imm32; + const u32 addr = index ? offset_addr : context.read_gpr(n); + + context.write_gpr(t, vm::psv::read32(addr)); if (wback) { - thr->write_gpr(n, offset_addr); + context.write_gpr(n, offset_addr); + } + } +} + +void ARMv7_instrs::LDR_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::LDR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + u32 cond = context.ITSTATE.advance(); + u32 t = 0; + u32 n = 0; + u32 m = 0; + bool index = true; + bool add = true; + bool wback = false; + auto shift_t = SRType_LSL; + u32 shift_n = 0; + + switch (type) + { + case T1: + { + t = (code.data & 0x7); + n = (code.data & 0x38) >> 3; + m = (code.data & 0x1c0) >> 6; + break; + } + case T2: + { + t = (code.data & 0xf000) >> 12; + n = (code.data & 0xf0000) >> 16; + m = (code.data & 0xf); + shift_n = (code.data & 0x30) >> 4; + + if (n == 15) + { + throw "LDR_REG_T2: LDR (literal)"; + } + break; + } + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } + + if (ConditionPassed(context, cond)) + { + const u32 offset = Shift(context.read_gpr(m), shift_t, shift_n, context.APSR.C); + const u32 offset_addr = add ? context.read_gpr(n) + offset : context.read_gpr(n) - offset; + const u32 addr = index ? offset_addr : context.read_gpr(n); + const u32 data = vm::psv::read32(addr); + + if (wback) + { + context.write_gpr(n, offset_addr); } - thr->write_gpr(t, vm::psv::read32(addr)); + context.write_gpr(t, data); } } -void ARMv7_instrs::LDR_LIT(ARMv7Thread* thr, const ARMv7_encoding type) + +void ARMv7_instrs::LDRB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1220,7 +1332,16 @@ void ARMv7_instrs::LDR_LIT(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDR_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRB_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::LDRB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1230,7 +1351,60 @@ void ARMv7_instrs::LDR_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::LDRB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRD_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + u32 cond = context.ITSTATE.advance(); + u32 t = 0; + u32 t2 = 0; + u32 n = 13; + u32 imm32 = 0; + bool index = true; + bool add = true; + bool wback = false; + + switch (type) + { + case T1: + { + t = (code.data & 0xf000) >> 12; + t2 = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; + imm32 = (code.data & 0xff) << 2; + index = (code.data & 0x1000000); + add = (code.data & 0x800000); + wback = (code.data & 0x200000); + + if (!index && !wback) + { + throw "LDRD_IMM_T1: Related encodings"; + } + if (n == 15) + { + throw "LDRD_IMM_T1: LDRD (literal)"; + } + break; + } + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } + + if (ConditionPassed(context, cond)) + { + const u32 offset_addr = add ? context.read_gpr(n) + imm32 : context.read_gpr(n) - imm32; + const u32 addr = index ? offset_addr : context.read_gpr(n); + const u64 value = vm::psv::read64(addr); + + context.write_gpr(t, (u32)(value)); + context.write_gpr(t2, (u32)(value >> 32)); + + if (wback) + { + context.write_gpr(n, offset_addr); + } + } +} + +void ARMv7_instrs::LDRD_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1239,16 +1413,7 @@ void ARMv7_instrs::LDRB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRB_LIT(ARMv7Thread* thr, const ARMv7_encoding type) -{ - switch (type) - { - case A1: throw __FUNCTION__; - default: throw __FUNCTION__; - } -} - -void ARMv7_instrs::LDRB_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRD_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1258,7 +1423,7 @@ void ARMv7_instrs::LDRB_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::LDRD_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRH_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1267,7 +1432,7 @@ void ARMv7_instrs::LDRD_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRD_LIT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRH_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1276,7 +1441,7 @@ void ARMv7_instrs::LDRD_LIT(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRD_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRH_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1286,7 +1451,7 @@ void ARMv7_instrs::LDRD_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::LDRH_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRSB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1295,7 +1460,7 @@ void ARMv7_instrs::LDRH_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRH_LIT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRSB_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1304,7 +1469,7 @@ void ARMv7_instrs::LDRH_LIT(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRH_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRSB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1314,7 +1479,7 @@ void ARMv7_instrs::LDRH_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::LDRSB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRSH_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1323,7 +1488,7 @@ void ARMv7_instrs::LDRSB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRSB_LIT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRSH_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1332,7 +1497,7 @@ void ARMv7_instrs::LDRSB_LIT(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRSB_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDRSH_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1342,7 +1507,38 @@ void ARMv7_instrs::LDRSB_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::LDRSH_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDREX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + u32 cond = context.ITSTATE.advance(); + u32 t = 0; + u32 n = 0; + u32 imm32 = 0; + + switch (type) + { + case T1: + { + t = (code.data & 0xf000) >> 12; + n = (code.data & 0xf0000) >> 16; + imm32 = (code.data & 0xff) << 2; + break; + } + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } + + if (ConditionPassed(context, cond)) + { + const u32 addr = context.read_gpr(n) + imm32; + const u32 value = vm::psv::read32(addr); + + context.R_ADDR = addr; + context.R_DATA = value; + context.write_gpr(t, value); + } +} + +void ARMv7_instrs::LDREXB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1351,7 +1547,7 @@ void ARMv7_instrs::LDRSH_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRSH_LIT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDREXD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1360,7 +1556,7 @@ void ARMv7_instrs::LDRSH_LIT(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LDRSH_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LDREXH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1370,10 +1566,10 @@ void ARMv7_instrs::LDRSH_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::LSL_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LSL_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - bool set_flags = !thr->ITSTATE; - u32 cond = thr->ITSTATE.advance(); + bool set_flags = !context.ITSTATE; + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 m = 0; u32 shift_n = 0; @@ -1382,26 +1578,26 @@ void ARMv7_instrs::LSL_IMM(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data & 0x7); - m = (thr->code.data & 0x38) >> 3; - shift_n = (thr->code.data & 0x7c0) >> 6; + d = (code.data & 0x7); + m = (code.data & 0x38) >> 3; + shift_n = (code.data & 0x7c0) >> 6; if (!shift_n) { - throw "MOV (register)"; + throw "LSL_IMM_T1: MOV (register)"; } break; } case T2: { - d = (thr->code.data & 0xf00) >> 8; - m = (thr->code.data & 0xf); - set_flags = (thr->code.data & 0x100000); - shift_n = (thr->code.data & 0x7000) >> 10 | (thr->code.data & 0xc0) >> 6; + d = (code.data & 0xf00) >> 8; + m = (code.data & 0xf); + set_flags = (code.data & 0x100000); + shift_n = (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6; if (!shift_n) { - throw "MOV (register)"; + throw "LSL_IMM_T2: MOV (register)"; } break; } @@ -1409,24 +1605,24 @@ void ARMv7_instrs::LSL_IMM(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { bool carry; - const u32 res = Shift_C(thr->read_gpr(m), SRType_LSL, shift_n, thr->APSR.C, carry); - thr->write_gpr(d, res); + const u32 res = Shift_C(context.read_gpr(m), SRType_LSL, shift_n, context.APSR.C, carry); + context.write_gpr(d, res); if (set_flags) { - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; } } } -void ARMv7_instrs::LSL_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LSL_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - bool set_flags = !thr->ITSTATE; - u32 cond = thr->ITSTATE.advance(); + bool set_flags = !context.ITSTATE; + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 n = 0; u32 m = 0; @@ -1435,38 +1631,38 @@ void ARMv7_instrs::LSL_REG(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = n = (thr->code.data & 0x7); - m = (thr->code.data & 0x38) >> 3; + d = n = (code.data & 0x7); + m = (code.data & 0x38) >> 3; break; } case T2: { - d = (thr->code.data & 0xf00) >> 8; - n = (thr->code.data & 0xf0000) >> 16; - m = (thr->code.data & 0xf); - set_flags = (thr->code.data & 0x100000); + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; + m = (code.data & 0xf); + set_flags = (code.data & 0x100000); break; } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { bool carry; - const u32 res = Shift_C(thr->read_gpr(n), SRType_LSL, (thr->read_gpr(m) & 0xff), thr->APSR.C, carry); - thr->write_gpr(d, res); + const u32 res = Shift_C(context.read_gpr(n), SRType_LSL, (context.read_gpr(m) & 0xff), context.APSR.C, carry); + context.write_gpr(d, res); if (set_flags) { - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; } } } -void ARMv7_instrs::LSR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LSR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1475,7 +1671,7 @@ void ARMv7_instrs::LSR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::LSR_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::LSR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1485,7 +1681,7 @@ void ARMv7_instrs::LSR_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::MLA(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MLA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1494,7 +1690,7 @@ void ARMv7_instrs::MLA(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::MLS(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MLS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1504,11 +1700,11 @@ void ARMv7_instrs::MLS(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::MOV_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MOV_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - bool set_flags = !thr->ITSTATE; - bool carry = thr->APSR.C; - u32 cond = thr->ITSTATE.advance(); + bool set_flags = !context.ITSTATE; + bool carry = context.APSR.C; + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 imm32 = 0; @@ -1516,42 +1712,42 @@ void ARMv7_instrs::MOV_IMM(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data >> 8) & 0x7; - imm32 = sign<8, u32>(thr->code.data & 0xff); + d = (code.data >> 8) & 0x7; + imm32 = sign<8, u32>(code.data & 0xff); break; } case T2: { - set_flags = thr->code.data & 0x100000; - d = (thr->code.data >> 8) & 0xf; - imm32 = ThumbExpandImm_C((thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff), carry, carry); + set_flags = code.data & 0x100000; + d = (code.data >> 8) & 0xf; + imm32 = ThumbExpandImm_C((code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff), carry, carry); break; } case T3: { set_flags = false; - d = (thr->code.data >> 8) & 0xf; - imm32 = (thr->code.data & 0xf0000) >> 4 | (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff); + d = (code.data >> 8) & 0xf; + imm32 = (code.data & 0xf0000) >> 4 | (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); break; } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - thr->write_gpr(d, imm32); + context.write_gpr(d, imm32); if (set_flags) { - thr->APSR.N = imm32 >> 31; - thr->APSR.Z = imm32 == 0; - thr->APSR.C = carry; + context.APSR.N = imm32 >> 31; + context.APSR.Z = imm32 == 0; + context.APSR.C = carry; } } } -void ARMv7_instrs::MOV_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MOV_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 m = 0; bool set_flags = false; @@ -1560,44 +1756,44 @@ void ARMv7_instrs::MOV_REG(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data & 0x80) >> 4 | (thr->code.data & 0x7); - m = (thr->code.data & 0x78) >> 3; + d = (code.data & 0x80) >> 4 | (code.data & 0x7); + m = (code.data & 0x78) >> 3; break; } case T2: { - d = (thr->code.data & 0x7); - m = (thr->code.data & 0x38) >> 3; + d = (code.data & 0x7); + m = (code.data & 0x38) >> 3; set_flags = true; break; } case T3: { - d = (thr->code.data & 0xf00) >> 8; - m = (thr->code.data & 0xf); - set_flags = (thr->code.data & 0x100000); + d = (code.data & 0xf00) >> 8; + m = (code.data & 0xf); + set_flags = (code.data & 0x100000); break; } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - const u32 res = thr->read_gpr(m); - thr->write_gpr(d, res); + const u32 res = context.read_gpr(m); + context.write_gpr(d, res); if (set_flags) { - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - //thr->APSR.C = ? + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + //context.APSR.C = ? } } } -void ARMv7_instrs::MOVT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MOVT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 imm16 = 0; @@ -1605,22 +1801,22 @@ void ARMv7_instrs::MOVT(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data & 0xf00) >> 8; - imm16 = (thr->code.data & 0xf0000) >> 4 | (thr->code.data & 0x4000000) >> 14 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff); + d = (code.data & 0xf00) >> 8; + imm16 = (code.data & 0xf0000) >> 4 | (code.data & 0x4000000) >> 14 | (code.data & 0x7000) >> 4 | (code.data & 0xff); break; } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - thr->write_gpr(d, (thr->read_gpr(d) & 0xffff) | (imm16 << 16)); + context.write_gpr(d, (context.read_gpr(d) & 0xffff) | (imm16 << 16)); } } -void ARMv7_instrs::MRS(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MRS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1629,7 +1825,7 @@ void ARMv7_instrs::MRS(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::MSR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MSR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1638,7 +1834,7 @@ void ARMv7_instrs::MSR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::MSR_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MSR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1648,7 +1844,69 @@ void ARMv7_instrs::MSR_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::MUL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::MUL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + bool set_flags = !context.ITSTATE; + u32 cond = context.ITSTATE.advance(); + u32 d = 0; + u32 n = 0; + u32 m = 0; + + switch (type) + { + case T1: + { + d = m = code.data & 0x7; + n = (code.data & 0x38) >> 3; + break; + } + case T2: + { + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; + m = (code.data & 0xf); + set_flags = false; + break; + } + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } + + if (ConditionPassed(context, cond)) + { + const u32 op1 = context.read_gpr(n); + const u32 op2 = context.read_gpr(m); + const u32 result = op1 * op2; + context.write_gpr(d, result); + + if (set_flags) + { + context.APSR.N = result >> 31; + context.APSR.Z = result == 0; + } + } +} + + +void ARMv7_instrs::MVN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::MVN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::MVN_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1658,37 +1916,9 @@ void ARMv7_instrs::MUL(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::MVN_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::NOP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - switch (type) - { - case A1: throw __FUNCTION__; - default: throw __FUNCTION__; - } -} - -void ARMv7_instrs::MVN_REG(ARMv7Thread* thr, const ARMv7_encoding type) -{ - switch (type) - { - case A1: throw __FUNCTION__; - default: throw __FUNCTION__; - } -} - -void ARMv7_instrs::MVN_RSR(ARMv7Thread* thr, const ARMv7_encoding type) -{ - switch (type) - { - case A1: throw __FUNCTION__; - default: throw __FUNCTION__; - } -} - - -void ARMv7_instrs::NOP(ARMv7Thread* thr, const ARMv7_encoding type) -{ - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); switch (type) { @@ -1702,19 +1932,19 @@ void ARMv7_instrs::NOP(ARMv7Thread* thr, const ARMv7_encoding type) } case A1: { - cond = thr->code.data >> 28; + cond = code.data >> 28; break; } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { } } -void ARMv7_instrs::ORN_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ORN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1723,7 +1953,7 @@ void ARMv7_instrs::ORN_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::ORN_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ORN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1733,7 +1963,7 @@ void ARMv7_instrs::ORN_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::ORR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ORR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1742,7 +1972,7 @@ void ARMv7_instrs::ORR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::ORR_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ORR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1751,7 +1981,7 @@ void ARMv7_instrs::ORR_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::ORR_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ORR_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1761,7 +1991,7 @@ void ARMv7_instrs::ORR_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::PKH(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::PKH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1771,116 +2001,122 @@ void ARMv7_instrs::PKH(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::POP(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::POP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u16 reg_list = 0; switch (type) { case T1: { - reg_list = ((thr->code.data & 0x100) << 7) | (thr->code.data & 0xff); + reg_list = ((code.data & 0x100) << 7) | (code.data & 0xff); break; } case T2: { - reg_list = thr->code.data & 0xdfff; + reg_list = code.data & 0xdfff; break; } case T3: { - reg_list = 1 << (thr->code.data >> 12); + reg_list = 1 << (code.data >> 12); break; } case A1: { - cond = thr->code.data >> 28; - reg_list = thr->code.data & 0xffff; + cond = code.data >> 28; + reg_list = code.data & 0xffff; if (BitCount(reg_list) < 2) { - throw "LDM / LDMIA / LDMFD"; + throw "POP_A1: LDM / LDMIA / LDMFD"; } break; } case A2: { - cond = thr->code.data >> 28; - reg_list = 1 << ((thr->code.data >> 12) & 0xf); + cond = code.data >> 28; + reg_list = 1 << ((code.data >> 12) & 0xf); break; } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { + u32 written = 0; for (u16 mask = 1, i = 0; mask; mask <<= 1, i++) { if (reg_list & mask) { - thr->write_gpr(i, vm::psv::read32(thr->SP)); - thr->SP += 4; + context.write_gpr(i, vm::psv::read32(context.SP + written)); + written += 4; } } + + context.SP += written; } } -void ARMv7_instrs::PUSH(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::PUSH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u16 reg_list = 0; switch (type) { case T1: { - reg_list = ((thr->code.data & 0x100) << 6) | (thr->code.data & 0xff); + reg_list = ((code.data & 0x100) << 6) | (code.data & 0xff); break; } case T2: { - reg_list = thr->code.data & 0x5fff; + reg_list = code.data & 0x5fff; break; } case T3: { - reg_list = 1 << (thr->code.data >> 12); + reg_list = 1 << (code.data >> 12); break; } case A1: { - cond = thr->code.data >> 28; - reg_list = thr->code.data & 0xffff; + cond = code.data >> 28; + reg_list = code.data & 0xffff; if (BitCount(reg_list) < 2) { - throw "STMDB / STMFD"; + throw "PUSH_A1: STMDB / STMFD"; } break; } case A2: { - cond = thr->code.data >> 28; - reg_list = 1 << ((thr->code.data >> 12) & 0xf); + cond = code.data >> 28; + reg_list = 1 << ((code.data >> 12) & 0xf); break; } default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { + u32 read = 0; for (u16 mask = 1 << 15, i = 15; mask; mask >>= 1, i--) { if (reg_list & mask) { - thr->SP -= 4; - vm::psv::write32(thr->SP, thr->read_gpr(i)); + read += 4; + vm::psv::write32(context.SP - read, context.read_gpr(i)); } } + + context.SP -= read; } } -void ARMv7_instrs::QADD(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1889,7 +2125,7 @@ void ARMv7_instrs::QADD(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QADD16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1898,7 +2134,7 @@ void ARMv7_instrs::QADD16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QADD8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1907,7 +2143,7 @@ void ARMv7_instrs::QADD8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QASX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1916,7 +2152,7 @@ void ARMv7_instrs::QASX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QDADD(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QDADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1925,7 +2161,7 @@ void ARMv7_instrs::QDADD(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QDSUB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QDSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1934,7 +2170,7 @@ void ARMv7_instrs::QDSUB(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QSAX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1943,7 +2179,7 @@ void ARMv7_instrs::QSAX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QSUB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1952,7 +2188,7 @@ void ARMv7_instrs::QSUB(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QSUB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1961,7 +2197,7 @@ void ARMv7_instrs::QSUB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::QSUB8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::QSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1971,7 +2207,7 @@ void ARMv7_instrs::QSUB8(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::RBIT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::RBIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1980,7 +2216,7 @@ void ARMv7_instrs::RBIT(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::REV(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::REV(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1989,7 +2225,7 @@ void ARMv7_instrs::REV(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::REV16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::REV16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -1998,7 +2234,7 @@ void ARMv7_instrs::REV16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::REVSH(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::REVSH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2008,7 +2244,7 @@ void ARMv7_instrs::REVSH(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::ROR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ROR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2017,7 +2253,7 @@ void ARMv7_instrs::ROR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::ROR_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::ROR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2027,7 +2263,7 @@ void ARMv7_instrs::ROR_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::RRX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::RRX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2037,7 +2273,7 @@ void ARMv7_instrs::RRX(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::RSB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::RSB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2046,7 +2282,7 @@ void ARMv7_instrs::RSB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::RSB_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::RSB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2055,7 +2291,7 @@ void ARMv7_instrs::RSB_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::RSB_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::RSB_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2065,7 +2301,7 @@ void ARMv7_instrs::RSB_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::RSC_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::RSC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2074,7 +2310,7 @@ void ARMv7_instrs::RSC_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::RSC_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::RSC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2083,7 +2319,7 @@ void ARMv7_instrs::RSC_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::RSC_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::RSC_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2093,7 +2329,7 @@ void ARMv7_instrs::RSC_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SADD16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2102,7 +2338,7 @@ void ARMv7_instrs::SADD16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SADD8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2111,7 +2347,7 @@ void ARMv7_instrs::SADD8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SASX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2121,7 +2357,7 @@ void ARMv7_instrs::SASX(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SBC_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SBC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2130,7 +2366,7 @@ void ARMv7_instrs::SBC_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SBC_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SBC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2139,7 +2375,7 @@ void ARMv7_instrs::SBC_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SBC_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SBC_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2149,7 +2385,7 @@ void ARMv7_instrs::SBC_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SBFX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SBFX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2159,7 +2395,7 @@ void ARMv7_instrs::SBFX(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SDIV(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SDIV(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2169,7 +2405,7 @@ void ARMv7_instrs::SDIV(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SEL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SEL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2179,7 +2415,7 @@ void ARMv7_instrs::SEL(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SHADD16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SHADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2188,7 +2424,7 @@ void ARMv7_instrs::SHADD16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SHADD8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SHADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2197,7 +2433,7 @@ void ARMv7_instrs::SHADD8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SHASX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SHASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2206,7 +2442,7 @@ void ARMv7_instrs::SHASX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SHSAX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SHSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2215,7 +2451,7 @@ void ARMv7_instrs::SHSAX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SHSUB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SHSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2224,7 +2460,7 @@ void ARMv7_instrs::SHSUB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SHSUB8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SHSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2234,7 +2470,7 @@ void ARMv7_instrs::SHSUB8(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SMLA__(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMLA__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2243,7 +2479,7 @@ void ARMv7_instrs::SMLA__(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMLAD(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMLAD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2252,7 +2488,7 @@ void ARMv7_instrs::SMLAD(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMLAL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMLAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2261,7 +2497,7 @@ void ARMv7_instrs::SMLAL(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMLAL__(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMLAL__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2270,7 +2506,7 @@ void ARMv7_instrs::SMLAL__(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMLALD(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMLALD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2279,7 +2515,7 @@ void ARMv7_instrs::SMLALD(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMLAW_(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMLAW_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2288,7 +2524,7 @@ void ARMv7_instrs::SMLAW_(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMLSD(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMLSD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2297,7 +2533,7 @@ void ARMv7_instrs::SMLSD(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMLSLD(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMLSLD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2306,7 +2542,7 @@ void ARMv7_instrs::SMLSLD(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMMLA(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMMLA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2315,7 +2551,7 @@ void ARMv7_instrs::SMMLA(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMMLS(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMMLS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2324,7 +2560,7 @@ void ARMv7_instrs::SMMLS(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMMUL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMMUL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2333,7 +2569,7 @@ void ARMv7_instrs::SMMUL(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMUAD(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMUAD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2342,7 +2578,7 @@ void ARMv7_instrs::SMUAD(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMUL__(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMUL__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2351,7 +2587,7 @@ void ARMv7_instrs::SMUL__(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMULL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMULL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2360,7 +2596,7 @@ void ARMv7_instrs::SMULL(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMULW_(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMULW_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2369,7 +2605,7 @@ void ARMv7_instrs::SMULW_(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SMUSD(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SMUSD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2379,7 +2615,7 @@ void ARMv7_instrs::SMUSD(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SSAT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SSAT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2388,7 +2624,7 @@ void ARMv7_instrs::SSAT(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SSAT16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SSAT16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2397,7 +2633,7 @@ void ARMv7_instrs::SSAT16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SSAX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2406,7 +2642,7 @@ void ARMv7_instrs::SSAX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SSUB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2415,7 +2651,7 @@ void ARMv7_instrs::SSUB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SSUB8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2425,7 +2661,7 @@ void ARMv7_instrs::SSUB8(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::STM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2434,7 +2670,7 @@ void ARMv7_instrs::STM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::STMDA(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STMDA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2443,7 +2679,7 @@ void ARMv7_instrs::STMDA(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::STMDB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STMDB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2452,7 +2688,7 @@ void ARMv7_instrs::STMDB(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::STMIB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STMIB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2462,9 +2698,9 @@ void ARMv7_instrs::STMIB(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::STR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 t = 16; u32 n = 13; u32 imm32 = 0; @@ -2476,22 +2712,22 @@ void ARMv7_instrs::STR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - t = (thr->code.data & 0x7); - n = (thr->code.data & 0x38) >> 3; - imm32 = (thr->code.data & 0x7c0) >> 4; + t = (code.data & 0x7); + n = (code.data & 0x38) >> 3; + imm32 = (code.data & 0x7c0) >> 4; break; } case T2: { - t = (thr->code.data & 0x700) >> 8; - imm32 = (thr->code.data & 0xff) << 2; + t = (code.data & 0x700) >> 8; + imm32 = (code.data & 0xff) << 2; break; } case T3: { - t = (thr->code.data & 0xf000) >> 12; - n = (thr->code.data & 0xf0000) >> 16; - imm32 = (thr->code.data & 0xfff); + t = (code.data & 0xf000) >> 12; + n = (code.data & 0xf0000) >> 16; + imm32 = (code.data & 0xfff); if (n == 0xf) { @@ -2501,20 +2737,20 @@ void ARMv7_instrs::STR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } case T4: { - t = (thr->code.data & 0xf000) >> 12; - n = (thr->code.data & 0xf0000) >> 16; - imm32 = (thr->code.data & 0xff); - index = (thr->code.data & 0x400); - add = (thr->code.data & 0x200); - wback = (thr->code.data & 0x100); + t = (code.data & 0xf000) >> 12; + n = (code.data & 0xf0000) >> 16; + imm32 = (code.data & 0xff); + index = (code.data & 0x400); + add = (code.data & 0x200); + wback = (code.data & 0x100); if (index && add && !wback) { - throw "STRT"; + throw "STR_IMM_T4: STRT"; } if (n == 13 && index && !add && wback && imm32 == 4) { - throw "PUSH"; + throw "STR_IMM_T4: PUSH"; } if (n == 15 || (!index && !wback)) { @@ -2526,23 +2762,23 @@ void ARMv7_instrs::STR_IMM(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - const u32 offset_addr = add ? thr->read_gpr(n) + imm32 : thr->read_gpr(n) - imm32; - const u32 addr = index ? offset_addr : thr->read_gpr(n); + const u32 offset_addr = add ? context.read_gpr(n) + imm32 : context.read_gpr(n) - imm32; + const u32 addr = index ? offset_addr : context.read_gpr(n); - vm::psv::write32(addr, thr->read_gpr(t)); + vm::psv::write32(addr, context.read_gpr(t)); if (wback) { - thr->write_gpr(n, offset_addr); + context.write_gpr(n, offset_addr); } } } -void ARMv7_instrs::STR_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 t = 0; u32 n = 0; u32 m = 0; @@ -2556,17 +2792,17 @@ void ARMv7_instrs::STR_REG(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - t = (thr->code.data & 0x7); - n = (thr->code.data & 0x38) >> 3; - m = (thr->code.data & 0x1c0) >> 6; + t = (code.data & 0x7); + n = (code.data & 0x38) >> 3; + m = (code.data & 0x1c0) >> 6; break; } case T2: { - t = (thr->code.data & 0xf000) >> 12; - n = (thr->code.data & 0xf0000) >> 16; - m = (thr->code.data & 0xf); - shift_n = (thr->code.data & 0x30) >> 4; + t = (code.data & 0xf000) >> 12; + n = (code.data & 0xf0000) >> 16; + m = (code.data & 0xf); + shift_n = (code.data & 0x30) >> 4; if (n == 15) { @@ -2578,23 +2814,23 @@ void ARMv7_instrs::STR_REG(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - const u32 offset = Shift(thr->read_gpr(m), shift_t, shift_n, thr->APSR.C); - const u32 offset_addr = add ? thr->read_gpr(n) + offset : thr->read_gpr(n) - offset; - const u32 addr = index ? offset_addr : thr->read_gpr(n); + const u32 offset = Shift(context.read_gpr(m), shift_t, shift_n, context.APSR.C); + const u32 offset_addr = add ? context.read_gpr(n) + offset : context.read_gpr(n) - offset; + const u32 addr = index ? offset_addr : context.read_gpr(n); - vm::psv::write32(addr, thr->read_gpr(t)); + vm::psv::write32(addr, context.read_gpr(t)); if (wback) { - thr->write_gpr(n, offset_addr); + context.write_gpr(n, offset_addr); } } } -void ARMv7_instrs::STRB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STRB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2603,7 +2839,7 @@ void ARMv7_instrs::STRB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::STRB_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STRB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2613,7 +2849,7 @@ void ARMv7_instrs::STRB_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::STRD_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STRD_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2622,7 +2858,7 @@ void ARMv7_instrs::STRD_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::STRD_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STRD_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2632,7 +2868,7 @@ void ARMv7_instrs::STRD_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::STRH_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STRH_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2641,7 +2877,7 @@ void ARMv7_instrs::STRH_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::STRH_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STRH_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2651,10 +2887,71 @@ void ARMv7_instrs::STRH_REG(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SUB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::STREX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - bool set_flags = !thr->ITSTATE; - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); + u32 d = 0; + u32 t = 0; + u32 n = 0; + u32 imm32 = 0; + + switch (type) + { + case T1: + { + d = (code.data & 0xf00) >> 8; + t = (code.data & 0xf000) >> 12; + n = (code.data & 0xf0000) >> 16; + imm32 = (code.data & 0xff) << 2; + break; + } + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } + + if (ConditionPassed(context, cond)) + { + const u32 addr = context.read_gpr(n) + imm32; + const u32 value = context.read_gpr(t); + + auto& sync_obj = vm::get_ref>(addr); + context.write_gpr(d, addr != context.R_ADDR || sync_obj.compare_and_swap((u32)context.R_DATA, value) != context.R_DATA); + context.R_ADDR = 0; + } +} + +void ARMv7_instrs::STREXB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::STREXD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::STREXH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + + +void ARMv7_instrs::SUB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + bool set_flags = !context.ITSTATE; + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 n = 0; u32 imm32 = 0; @@ -2663,48 +2960,48 @@ void ARMv7_instrs::SUB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data & 0x7); - n = (thr->code.data & 0x38) >> 3; - imm32 = (thr->code.data & 0x1c) >> 6; + d = (code.data & 0x7); + n = (code.data & 0x38) >> 3; + imm32 = (code.data & 0x1c) >> 6; break; } case T2: { - d = n = (thr->code.data & 0x700) >> 8; - imm32 = (thr->code.data & 0xff); + d = n = (code.data & 0x700) >> 8; + imm32 = (code.data & 0xff); break; } case T3: { - d = (thr->code.data & 0xf00) >> 8; - n = (thr->code.data & 0xf0000) >> 16; - set_flags = (thr->code.data & 0x100000); - imm32 = ThumbExpandImm(thr, (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff)); + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; + set_flags = (code.data & 0x100000); + imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); if (d == 15 && set_flags) { - throw "CMP (immediate)"; + throw "SUB_IMM_T3: CMP (immediate)"; } if (n == 13) { - throw "SUB (SP minus immediate)"; + throw "SUB_IMM_T3: SUB (SP minus immediate)"; } break; } case T4: { - d = (thr->code.data & 0xf00) >> 8; - n = (thr->code.data & 0xf0000) >> 16; + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; set_flags = false; - imm32 = (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff); + imm32 = (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); if (d == 15) { - throw "ADR"; + throw "SUB_IMM_T4: ADR"; } if (n == 13) { - throw "SUB (SP minus immediate)"; + throw "SUB_IMM_T4: SUB (SP minus immediate)"; } break; } @@ -2712,29 +3009,29 @@ void ARMv7_instrs::SUB_IMM(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { if (set_flags) { bool carry, overflow; - const u32 res = AddWithCarry(thr->read_gpr(n), ~imm32, true, carry, overflow); - thr->write_gpr(d, res); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 res = AddWithCarry(context.read_gpr(n), ~imm32, true, carry, overflow); + context.write_gpr(d, res); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } else { - thr->write_gpr(d, thr->read_gpr(n) - imm32); + context.write_gpr(d, context.read_gpr(n) - imm32); } } } -void ARMv7_instrs::SUB_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SUB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - bool set_flags = !thr->ITSTATE; - u32 cond = thr->ITSTATE.advance(); + bool set_flags = !context.ITSTATE; + u32 cond = context.ITSTATE.advance(); u32 d = 0; u32 n = 0; u32 m = 0; @@ -2745,26 +3042,26 @@ void ARMv7_instrs::SUB_REG(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - d = (thr->code.data & 0x7); - n = (thr->code.data & 0x38) >> 3; - m = (thr->code.data & 0x1c0) >> 6; + d = (code.data & 0x7); + n = (code.data & 0x38) >> 3; + m = (code.data & 0x1c0) >> 6; break; } case T2: { - d = (thr->code.data & 0xf00) >> 8; - n = (thr->code.data & 0xf0000) >> 16; - m = (thr->code.data & 0xf); - set_flags = (thr->code.data & 0x100000); - shift_t = DecodeImmShift((thr->code.data & 0x30) >> 4, (thr->code.data & 0x7000) >> 10 | (thr->code.data & 0xc0) >> 6, &shift_n); + d = (code.data & 0xf00) >> 8; + n = (code.data & 0xf0000) >> 16; + m = (code.data & 0xf); + set_flags = (code.data & 0x100000); + shift_t = DecodeImmShift((code.data & 0x30) >> 4, (code.data & 0x7000) >> 10 | (code.data & 0xc0) >> 6, &shift_n); if (d == 15 && set_flags) { - throw "CMP (register)"; + throw "SUB_REG_T2: CMP (register)"; } if (n == 13) { - throw "SUB (SP minus register)"; + throw "SUB_REG_T2: SUB (SP minus register)"; } break; } @@ -2772,27 +3069,27 @@ void ARMv7_instrs::SUB_REG(ARMv7Thread* thr, const ARMv7_encoding type) default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { - const u32 shifted = Shift(thr->read_gpr(m), shift_t, shift_n, thr->APSR.C); + const u32 shifted = Shift(context.read_gpr(m), shift_t, shift_n, context.APSR.C); if (set_flags) { bool carry, overflow; - const u32 res = AddWithCarry(thr->read_gpr(n), ~shifted, true, carry, overflow); - thr->write_gpr(d, res); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 res = AddWithCarry(context.read_gpr(n), ~shifted, true, carry, overflow); + context.write_gpr(d, res); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } else { - thr->write_gpr(d, thr->read_gpr(n) - shifted); + context.write_gpr(d, context.read_gpr(n) - shifted); } } } -void ARMv7_instrs::SUB_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SUB_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2801,9 +3098,9 @@ void ARMv7_instrs::SUB_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SUB_SPI(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SUB_SPI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { - u32 cond = thr->ITSTATE.advance(); + u32 cond = context.ITSTATE.advance(); u32 d = 13; bool set_flags = false; u32 imm32 = 0; @@ -2812,52 +3109,52 @@ void ARMv7_instrs::SUB_SPI(ARMv7Thread* thr, const ARMv7_encoding type) { case T1: { - imm32 = (thr->code.data & 0x7f) << 2; + imm32 = (code.data & 0x7f) << 2; break; } case T2: { - d = (thr->code.data & 0xf00) >> 8; - set_flags = (thr->code.data & 0x100000); - imm32 = ThumbExpandImm(thr, (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff)); + d = (code.data & 0xf00) >> 8; + set_flags = (code.data & 0x100000); + imm32 = ThumbExpandImm(context, (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff)); if (d == 15 && set_flags) { - throw "CMP (immediate)"; + throw "SUB_SPI_T2: CMP (immediate)"; } break; } case T3: { - d = (thr->code.data & 0xf00) >> 8; + d = (code.data & 0xf00) >> 8; set_flags = false; - imm32 = (thr->code.data & 0x4000000) >> 15 | (thr->code.data & 0x7000) >> 4 | (thr->code.data & 0xff); + imm32 = (code.data & 0x4000000) >> 15 | (code.data & 0x7000) >> 4 | (code.data & 0xff); break; } case A1: throw __FUNCTION__; default: throw __FUNCTION__; } - if (ConditionPassed(thr, cond)) + if (ConditionPassed(context, cond)) { if (set_flags) { bool carry, overflow; - const u32 res = AddWithCarry(thr->SP, ~imm32, true, carry, overflow); - thr->write_gpr(d, res); - thr->APSR.N = res >> 31; - thr->APSR.Z = res == 0; - thr->APSR.C = carry; - thr->APSR.V = overflow; + const u32 res = AddWithCarry(context.SP, ~imm32, true, carry, overflow); + context.write_gpr(d, res); + context.APSR.N = res >> 31; + context.APSR.Z = res == 0; + context.APSR.C = carry; + context.APSR.V = overflow; } else { - thr->write_gpr(d, thr->SP - imm32); + context.write_gpr(d, context.SP - imm32); } } } -void ARMv7_instrs::SUB_SPR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SUB_SPR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2867,7 +3164,7 @@ void ARMv7_instrs::SUB_SPR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SVC(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SVC(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2877,7 +3174,7 @@ void ARMv7_instrs::SVC(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::SXTAB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SXTAB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2886,7 +3183,7 @@ void ARMv7_instrs::SXTAB(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SXTAB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SXTAB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2895,7 +3192,7 @@ void ARMv7_instrs::SXTAB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SXTAH(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SXTAH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2904,7 +3201,7 @@ void ARMv7_instrs::SXTAH(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SXTB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SXTB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2913,7 +3210,7 @@ void ARMv7_instrs::SXTB(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SXTB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SXTB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2922,7 +3219,7 @@ void ARMv7_instrs::SXTB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::SXTH(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::SXTH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2932,7 +3229,7 @@ void ARMv7_instrs::SXTH(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::TB_(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::TB_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2942,7 +3239,7 @@ void ARMv7_instrs::TB_(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::TEQ_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::TEQ_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2951,7 +3248,7 @@ void ARMv7_instrs::TEQ_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::TEQ_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::TEQ_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2960,7 +3257,7 @@ void ARMv7_instrs::TEQ_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::TEQ_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::TEQ_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2970,7 +3267,7 @@ void ARMv7_instrs::TEQ_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::TST_IMM(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::TST_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2979,7 +3276,7 @@ void ARMv7_instrs::TST_IMM(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::TST_REG(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::TST_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2988,7 +3285,7 @@ void ARMv7_instrs::TST_REG(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::TST_RSR(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::TST_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -2998,7 +3295,7 @@ void ARMv7_instrs::TST_RSR(ARMv7Thread* thr, const ARMv7_encoding type) } -void ARMv7_instrs::UADD16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3007,7 +3304,7 @@ void ARMv7_instrs::UADD16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UADD8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3016,7 +3313,7 @@ void ARMv7_instrs::UADD8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UASX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3025,7 +3322,7 @@ void ARMv7_instrs::UASX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UBFX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UBFX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3034,7 +3331,7 @@ void ARMv7_instrs::UBFX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UDIV(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UDIV(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3043,7 +3340,7 @@ void ARMv7_instrs::UDIV(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UHADD16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UHADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3052,7 +3349,7 @@ void ARMv7_instrs::UHADD16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UHADD8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UHADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3061,7 +3358,7 @@ void ARMv7_instrs::UHADD8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UHASX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UHASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3070,7 +3367,7 @@ void ARMv7_instrs::UHASX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UHSAX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UHSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3079,7 +3376,7 @@ void ARMv7_instrs::UHSAX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UHSUB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UHSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3088,7 +3385,7 @@ void ARMv7_instrs::UHSUB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UHSUB8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UHSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3097,7 +3394,7 @@ void ARMv7_instrs::UHSUB8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UMAAL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UMAAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3106,7 +3403,7 @@ void ARMv7_instrs::UMAAL(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UMLAL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UMLAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3115,7 +3412,7 @@ void ARMv7_instrs::UMLAL(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UMULL(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UMULL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3124,7 +3421,7 @@ void ARMv7_instrs::UMULL(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UQADD16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UQADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3133,7 +3430,7 @@ void ARMv7_instrs::UQADD16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UQADD8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UQADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3142,7 +3439,7 @@ void ARMv7_instrs::UQADD8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UQASX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UQASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3151,7 +3448,7 @@ void ARMv7_instrs::UQASX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UQSAX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UQSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3160,7 +3457,7 @@ void ARMv7_instrs::UQSAX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UQSUB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UQSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3169,7 +3466,7 @@ void ARMv7_instrs::UQSUB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UQSUB8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UQSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3178,7 +3475,7 @@ void ARMv7_instrs::UQSUB8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::USAD8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::USAD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3187,7 +3484,7 @@ void ARMv7_instrs::USAD8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::USADA8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::USADA8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3196,7 +3493,7 @@ void ARMv7_instrs::USADA8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::USAT(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::USAT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3205,7 +3502,7 @@ void ARMv7_instrs::USAT(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::USAT16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::USAT16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3214,7 +3511,7 @@ void ARMv7_instrs::USAT16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::USAX(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::USAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3223,7 +3520,7 @@ void ARMv7_instrs::USAX(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::USUB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::USUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3232,7 +3529,7 @@ void ARMv7_instrs::USUB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::USUB8(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::USUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3241,7 +3538,7 @@ void ARMv7_instrs::USUB8(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UXTAB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UXTAB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3250,7 +3547,7 @@ void ARMv7_instrs::UXTAB(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UXTAB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UXTAB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3259,7 +3556,7 @@ void ARMv7_instrs::UXTAB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UXTAH(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UXTAH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3268,7 +3565,7 @@ void ARMv7_instrs::UXTAH(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UXTB(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UXTB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3277,7 +3574,7 @@ void ARMv7_instrs::UXTB(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UXTB16(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UXTB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { @@ -3286,11 +3583,1255 @@ void ARMv7_instrs::UXTB16(ARMv7Thread* thr, const ARMv7_encoding type) } } -void ARMv7_instrs::UXTH(ARMv7Thread* thr, const ARMv7_encoding type) +void ARMv7_instrs::UXTH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { switch (type) { case A1: throw __FUNCTION__; default: throw __FUNCTION__; } -} \ No newline at end of file +} + + +void ARMv7_instrs::VABA_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VABD_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VABD_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VABS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VAC__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VADD_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VADDHN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VADD_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VAND(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VBIC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VBIC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VB__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCEQ_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCEQ_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCGE_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCGE_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCGT_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCGT_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCLE_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCLS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCLT_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCLZ(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCMP_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCNT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCVT_FIA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCVT_FIF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCVT_FFA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCVT_FFF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCVT_DF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCVT_HFA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VCVT_HFF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VDIV(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VDUP_S(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VDUP_R(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VEOR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VEXT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VHADDSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD__MS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD1_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD1_SAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD2_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD2_SAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD3_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD3_SAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD4_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLD4_SAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLDM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VLDR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMAXMIN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMAXMIN_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VML__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VML__FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VML__S(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOV_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOV_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOV_RS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOV_SR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOV_RF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOV_2RF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOV_2RD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOVL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMOVN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMRS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMUL_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMUL_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMUL_S(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMVN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VMVN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VNEG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VNM__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VORN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VORR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VORR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VPADAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VPADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VPADD_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VPADDL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VPMAXMIN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VPMAXMIN_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VPOP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VPUSH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQABS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQDML_L(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQDMULH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQDMULL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQMOV_N(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQNEG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQRDMULH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQRSHL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQRSHR_N(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQSHL_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQSHL_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQSHR_N(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VQSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRADDHN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRECPE(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRECPS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VREV__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRHADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRSHL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRSHR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRSHRN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRSQRTE(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRSQRTS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRSRA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VRSUBHN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSHL_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSHL_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSHLL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSHR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSHRN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSLI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSQRT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSRA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSRI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VST__MS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VST1_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VST2_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VST3_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VST4_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSTM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSTR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSUB_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSUBHN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSUB_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VSWP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VTB_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VTRN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VTST(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VUZP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::VZIP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + + +void ARMv7_instrs::WFE(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::WFI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} + +void ARMv7_instrs::YIELD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) +{ + switch (type) + { + case A1: throw __FUNCTION__; + default: throw __FUNCTION__; + } +} diff --git a/rpcs3/Emu/ARMv7/ARMv7Interpreter.h b/rpcs3/Emu/ARMv7/ARMv7Interpreter.h index 0cd02aecf7..c99958a35c 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Interpreter.h +++ b/rpcs3/Emu/ARMv7/ARMv7Interpreter.h @@ -1,8 +1,15 @@ #pragma once -#include "Emu/ARMv7/ARMv7Thread.h" -#include "Emu/System.h" -#include "Utilities/Log.h" +union ARMv7Code +{ + struct + { + u16 code0; + u16 code1; + }; + + u32 data; +}; enum ARMv7_encoding { @@ -61,18 +68,18 @@ namespace ARMv7_instrs SRType DecodeRegShift(u8 type); u32 LSL_C(u32 x, s32 shift, bool& carry_out); - u32 LSL(u32 x, s32 shift); + u32 LSL_(u32 x, s32 shift); u32 LSR_C(u32 x, s32 shift, bool& carry_out); - u32 LSR(u32 x, s32 shift); + u32 LSR_(u32 x, s32 shift); s32 ASR_C(s32 x, s32 shift, bool& carry_out); - s32 ASR(s32 x, s32 shift); + s32 ASR_(s32 x, s32 shift); u32 ROR_C(u32 x, s32 shift, bool& carry_out); - u32 ROR(u32 x, s32 shift); + u32 ROR_(u32 x, s32 shift); u32 RRX_C(u32 x, bool carry_in, bool& carry_out); - u32 RRX(u32 x, bool carry_in); + u32 RRX_(u32 x, bool carry_in); template T Shift_C(T value, SRType type, s32 amount, bool carry_in, bool& carry_out); @@ -81,679 +88,433 @@ namespace ARMv7_instrs template T AddWithCarry(T x, T y, bool carry_in, bool& carry_out, bool& overflow); u32 ThumbExpandImm_C(u32 imm12, bool carry_in, bool& carry_out); - u32 ThumbExpandImm(ARMv7Thread* CPU, u32 imm12); + u32 ThumbExpandImm(ARMv7Context& context, u32 imm12); - bool ConditionPassed(ARMv7Thread* CPU, u32 cond); + bool ConditionPassed(ARMv7Context& context, u32 cond); // instructions - void UNK(ARMv7Thread* thr); + void UNK(ARMv7Context& context, const ARMv7Code code); - void NULL_OP(ARMv7Thread* thr, const ARMv7_encoding type); + void NULL_OP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void HACK(ARMv7Thread* thr, const ARMv7_encoding type); + void HACK(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void ADC_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void ADC_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void ADC_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void MRC_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void ADD_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void ADD_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void ADD_RSR(ARMv7Thread* thr, const ARMv7_encoding type); - void ADD_SPI(ARMv7Thread* thr, const ARMv7_encoding type); - void ADD_SPR(ARMv7Thread* thr, const ARMv7_encoding type); + void ADC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ADC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ADC_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void ADR(ARMv7Thread* thr, const ARMv7_encoding type); + void ADD_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ADD_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ADD_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ADD_SPI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ADD_SPR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void AND_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void AND_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void AND_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void ADR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void ASR_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void ASR_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void AND_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void AND_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void AND_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void B(ARMv7Thread* thr, const ARMv7_encoding type); + void ASR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ASR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void BFC(ARMv7Thread* thr, const ARMv7_encoding type); - void BFI(ARMv7Thread* thr, const ARMv7_encoding type); + void B(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void BIC_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void BIC_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void BIC_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void BFC(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void BFI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void BKPT(ARMv7Thread* thr, const ARMv7_encoding type); + void BIC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void BIC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void BIC_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void BL(ARMv7Thread* thr, const ARMv7_encoding type); - void BLX(ARMv7Thread* thr, const ARMv7_encoding type); - void BX(ARMv7Thread* thr, const ARMv7_encoding type); + void BKPT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void CB_Z(ARMv7Thread* thr, const ARMv7_encoding type); + void BL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void BLX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void BX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void CLZ(ARMv7Thread* thr, const ARMv7_encoding type); + void CB_Z(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void CMN_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void CMN_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void CMN_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void CLZ(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void CMP_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void CMP_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void CMP_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void CMN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void CMN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void CMN_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void EOR_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void EOR_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void EOR_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void CMP_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void CMP_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void CMP_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void IT(ARMv7Thread* thr, const ARMv7_encoding type); + void EOR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void EOR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void EOR_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LDM(ARMv7Thread* thr, const ARMv7_encoding type); - void LDMDA(ARMv7Thread* thr, const ARMv7_encoding type); - void LDMDB(ARMv7Thread* thr, const ARMv7_encoding type); - void LDMIB(ARMv7Thread* thr, const ARMv7_encoding type); + void IT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LDR_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void LDR_LIT(ARMv7Thread* thr, const ARMv7_encoding type); - void LDR_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void LDM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDMDA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDMDB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDMIB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LDRB_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRB_LIT(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRB_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void LDR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDR_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LDRD_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRD_LIT(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRD_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void LDRB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRB_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LDRH_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRH_LIT(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRH_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void LDRD_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRD_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRD_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LDRSB_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRSB_LIT(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRSB_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void LDRH_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRH_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRH_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LDRSH_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRSH_LIT(ARMv7Thread* thr, const ARMv7_encoding type); - void LDRSH_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void LDRSB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRSB_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRSB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LSL_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void LSL_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void LDRSH_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRSH_LIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDRSH_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void LSR_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void LSR_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void LDREX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDREXB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDREXD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LDREXH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void MLA(ARMv7Thread* thr, const ARMv7_encoding type); - void MLS(ARMv7Thread* thr, const ARMv7_encoding type); + void LSL_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LSL_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void MOV_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void MOV_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void MOVT(ARMv7Thread* thr, const ARMv7_encoding type); + void LSR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void LSR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void MRS(ARMv7Thread* thr, const ARMv7_encoding type); - void MSR_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void MSR_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void MLA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void MLS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void MUL(ARMv7Thread* thr, const ARMv7_encoding type); + void MOV_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void MOV_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void MOVT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void MVN_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void MVN_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void MVN_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void MRS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void MSR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void MSR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void NOP(ARMv7Thread* thr, const ARMv7_encoding type); + void MUL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void ORN_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void ORN_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void MVN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void MVN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void MVN_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void ORR_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void ORR_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void ORR_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void NOP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void PKH(ARMv7Thread* thr, const ARMv7_encoding type); + void ORN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ORN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void POP(ARMv7Thread* thr, const ARMv7_encoding type); - void PUSH(ARMv7Thread* thr, const ARMv7_encoding type); + void ORR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ORR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ORR_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void QADD(ARMv7Thread* thr, const ARMv7_encoding type); - void QADD16(ARMv7Thread* thr, const ARMv7_encoding type); - void QADD8(ARMv7Thread* thr, const ARMv7_encoding type); - void QASX(ARMv7Thread* thr, const ARMv7_encoding type); - void QDADD(ARMv7Thread* thr, const ARMv7_encoding type); - void QDSUB(ARMv7Thread* thr, const ARMv7_encoding type); - void QSAX(ARMv7Thread* thr, const ARMv7_encoding type); - void QSUB(ARMv7Thread* thr, const ARMv7_encoding type); - void QSUB16(ARMv7Thread* thr, const ARMv7_encoding type); - void QSUB8(ARMv7Thread* thr, const ARMv7_encoding type); + void PKH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void RBIT(ARMv7Thread* thr, const ARMv7_encoding type); - void REV(ARMv7Thread* thr, const ARMv7_encoding type); - void REV16(ARMv7Thread* thr, const ARMv7_encoding type); - void REVSH(ARMv7Thread* thr, const ARMv7_encoding type); + void POP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void PUSH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void ROR_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void ROR_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void QADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QDADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QDSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void QSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void RRX(ARMv7Thread* thr, const ARMv7_encoding type); + void RBIT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void REV(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void REV16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void REVSH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void RSB_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void RSB_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void RSB_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void ROR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void ROR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void RSC_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void RSC_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void RSC_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void RRX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SADD16(ARMv7Thread* thr, const ARMv7_encoding type); - void SADD8(ARMv7Thread* thr, const ARMv7_encoding type); - void SASX(ARMv7Thread* thr, const ARMv7_encoding type); + void RSB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void RSB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void RSB_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SBC_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void SBC_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void SBC_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void RSC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void RSC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void RSC_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SBFX(ARMv7Thread* thr, const ARMv7_encoding type); + void SADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SDIV(ARMv7Thread* thr, const ARMv7_encoding type); + void SBC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SBC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SBC_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SEL(ARMv7Thread* thr, const ARMv7_encoding type); + void SBFX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SHADD16(ARMv7Thread* thr, const ARMv7_encoding type); - void SHADD8(ARMv7Thread* thr, const ARMv7_encoding type); - void SHASX(ARMv7Thread* thr, const ARMv7_encoding type); - void SHSAX(ARMv7Thread* thr, const ARMv7_encoding type); - void SHSUB16(ARMv7Thread* thr, const ARMv7_encoding type); - void SHSUB8(ARMv7Thread* thr, const ARMv7_encoding type); + void SDIV(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SMLA__(ARMv7Thread* thr, const ARMv7_encoding type); - void SMLAD(ARMv7Thread* thr, const ARMv7_encoding type); - void SMLAL(ARMv7Thread* thr, const ARMv7_encoding type); - void SMLAL__(ARMv7Thread* thr, const ARMv7_encoding type); - void SMLALD(ARMv7Thread* thr, const ARMv7_encoding type); - void SMLAW_(ARMv7Thread* thr, const ARMv7_encoding type); - void SMLSD(ARMv7Thread* thr, const ARMv7_encoding type); - void SMLSLD(ARMv7Thread* thr, const ARMv7_encoding type); - void SMMLA(ARMv7Thread* thr, const ARMv7_encoding type); - void SMMLS(ARMv7Thread* thr, const ARMv7_encoding type); - void SMMUL(ARMv7Thread* thr, const ARMv7_encoding type); - void SMUAD(ARMv7Thread* thr, const ARMv7_encoding type); - void SMUL__(ARMv7Thread* thr, const ARMv7_encoding type); - void SMULL(ARMv7Thread* thr, const ARMv7_encoding type); - void SMULW_(ARMv7Thread* thr, const ARMv7_encoding type); - void SMUSD(ARMv7Thread* thr, const ARMv7_encoding type); + void SEL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SSAT(ARMv7Thread* thr, const ARMv7_encoding type); - void SSAT16(ARMv7Thread* thr, const ARMv7_encoding type); - void SSAX(ARMv7Thread* thr, const ARMv7_encoding type); - void SSUB16(ARMv7Thread* thr, const ARMv7_encoding type); - void SSUB8(ARMv7Thread* thr, const ARMv7_encoding type); + void SHADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SHADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SHASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SHSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SHSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SHSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void STM(ARMv7Thread* thr, const ARMv7_encoding type); - void STMDA(ARMv7Thread* thr, const ARMv7_encoding type); - void STMDB(ARMv7Thread* thr, const ARMv7_encoding type); - void STMIB(ARMv7Thread* thr, const ARMv7_encoding type); + void SMLA__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMLAD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMLAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMLAL__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMLALD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMLAW_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMLSD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMLSLD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMMLA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMMLS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMMUL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMUAD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMUL__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMULL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMULW_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SMUSD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void STR_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void STR_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void SSAT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SSAT16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void STRB_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void STRB_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void STM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STMDA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STMDB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STMIB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void STRD_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void STRD_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void STR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void STRH_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void STRH_REG(ARMv7Thread* thr, const ARMv7_encoding type); + void STRB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STRB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SUB_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void SUB_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void SUB_RSR(ARMv7Thread* thr, const ARMv7_encoding type); - void SUB_SPI(ARMv7Thread* thr, const ARMv7_encoding type); - void SUB_SPR(ARMv7Thread* thr, const ARMv7_encoding type); + void STRD_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STRD_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SVC(ARMv7Thread* thr, const ARMv7_encoding type); + void STRH_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STRH_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void SXTAB(ARMv7Thread* thr, const ARMv7_encoding type); - void SXTAB16(ARMv7Thread* thr, const ARMv7_encoding type); - void SXTAH(ARMv7Thread* thr, const ARMv7_encoding type); - void SXTB(ARMv7Thread* thr, const ARMv7_encoding type); - void SXTB16(ARMv7Thread* thr, const ARMv7_encoding type); - void SXTH(ARMv7Thread* thr, const ARMv7_encoding type); + void STREX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STREXB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STREXD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void STREXH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void TB_(ARMv7Thread* thr, const ARMv7_encoding type); + void SUB_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SUB_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SUB_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SUB_SPI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SUB_SPR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void TEQ_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void TEQ_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void TEQ_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void SVC(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void TST_IMM(ARMv7Thread* thr, const ARMv7_encoding type); - void TST_REG(ARMv7Thread* thr, const ARMv7_encoding type); - void TST_RSR(ARMv7Thread* thr, const ARMv7_encoding type); + void SXTAB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SXTAB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SXTAH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SXTB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SXTB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void SXTH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); - void UADD16(ARMv7Thread* thr, const ARMv7_encoding type); - void UADD8(ARMv7Thread* thr, const ARMv7_encoding type); - void UASX(ARMv7Thread* thr, const ARMv7_encoding type); - void UBFX(ARMv7Thread* thr, const ARMv7_encoding type); - void UDIV(ARMv7Thread* thr, const ARMv7_encoding type); - void UHADD16(ARMv7Thread* thr, const ARMv7_encoding type); - void UHADD8(ARMv7Thread* thr, const ARMv7_encoding type); - void UHASX(ARMv7Thread* thr, const ARMv7_encoding type); - void UHSAX(ARMv7Thread* thr, const ARMv7_encoding type); - void UHSUB16(ARMv7Thread* thr, const ARMv7_encoding type); - void UHSUB8(ARMv7Thread* thr, const ARMv7_encoding type); - void UMAAL(ARMv7Thread* thr, const ARMv7_encoding type); - void UMLAL(ARMv7Thread* thr, const ARMv7_encoding type); - void UMULL(ARMv7Thread* thr, const ARMv7_encoding type); - void UQADD16(ARMv7Thread* thr, const ARMv7_encoding type); - void UQADD8(ARMv7Thread* thr, const ARMv7_encoding type); - void UQASX(ARMv7Thread* thr, const ARMv7_encoding type); - void UQSAX(ARMv7Thread* thr, const ARMv7_encoding type); - void UQSUB16(ARMv7Thread* thr, const ARMv7_encoding type); - void UQSUB8(ARMv7Thread* thr, const ARMv7_encoding type); - void USAD8(ARMv7Thread* thr, const ARMv7_encoding type); - void USADA8(ARMv7Thread* thr, const ARMv7_encoding type); - void USAT(ARMv7Thread* thr, const ARMv7_encoding type); - void USAT16(ARMv7Thread* thr, const ARMv7_encoding type); - void USAX(ARMv7Thread* thr, const ARMv7_encoding type); - void USUB16(ARMv7Thread* thr, const ARMv7_encoding type); - void USUB8(ARMv7Thread* thr, const ARMv7_encoding type); - void UXTAB(ARMv7Thread* thr, const ARMv7_encoding type); - void UXTAB16(ARMv7Thread* thr, const ARMv7_encoding type); - void UXTAH(ARMv7Thread* thr, const ARMv7_encoding type); - void UXTB(ARMv7Thread* thr, const ARMv7_encoding type); - void UXTB16(ARMv7Thread* thr, const ARMv7_encoding type); - void UXTH(ARMv7Thread* thr, const ARMv7_encoding type); + void TB_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + + void TEQ_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void TEQ_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void TEQ_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + + void TST_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void TST_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void TST_RSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + + void UADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UBFX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UDIV(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UHADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UHADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UHASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UHSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UHSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UHSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UMAAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UMLAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UMULL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UQADD16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UQADD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UQASX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UQSAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UQSUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UQSUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void USAD8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void USADA8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void USAT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void USAT16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void USAX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void USUB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void USUB8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UXTAB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UXTAB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UXTAH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UXTB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UXTB16(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void UXTH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + + void VABA_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VABD_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VABD_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VABS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VAC__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VADD_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VADDHN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VADD_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VAND(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VBIC_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VBIC_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VB__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCEQ_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCEQ_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCGE_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCGE_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCGT_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCGT_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCLE_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCLS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCLT_ZERO(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCLZ(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCMP_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCNT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCVT_FIA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCVT_FIF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCVT_FFA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCVT_FFF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCVT_DF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCVT_HFA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VCVT_HFF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VDIV(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VDUP_S(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VDUP_R(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VEOR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VEXT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VHADDSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD__MS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD1_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD1_SAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD2_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD2_SAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD3_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD3_SAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD4_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLD4_SAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLDM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VLDR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMAXMIN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMAXMIN_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VML__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VML__FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VML__S(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOV_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOV_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOV_RS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOV_SR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOV_RF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOV_2RF(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOV_2RD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOVL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMOVN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMRS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMSR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMUL_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMUL_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMUL_S(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMVN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VMVN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VNEG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VNM__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VORN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VORR_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VORR_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VPADAL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VPADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VPADD_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VPADDL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VPMAXMIN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VPMAXMIN_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VPOP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VPUSH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQABS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQDML_L(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQDMULH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQDMULL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQMOV_N(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQNEG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQRDMULH(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQRSHL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQRSHR_N(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQSHL_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQSHL_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQSHR_N(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VQSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRADDHN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRECPE(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRECPS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VREV__(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRHADD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRSHL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRSHR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRSHRN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRSQRTE(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRSQRTS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRSRA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VRSUBHN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSHL_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSHL_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSHLL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSHR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSHRN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSLI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSQRT(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSRA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSRI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VST__MS(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VST1_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VST2_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VST3_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VST4_SL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSTM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSTR(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSUB(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSUB_FP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSUBHN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSUB_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VSWP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VTB_(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VTRN(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VTST(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VUZP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void VZIP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + + void WFE(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void WFI(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); + void YIELD(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); }; - - -// old instructions table for debugging and information, delete this later -using namespace ARMv7_instrs; - -struct ARMv7_opcode_t -{ - u32 mask; - u32 code; - u32 length; // 2 or 4 - const char* name; - ARMv7_encoding type; - void(*func)(ARMv7Thread* thr, const ARMv7_encoding type); -}; - -// single 16-bit value -#define ARMv7_OP2(mask, code, type, name) { (u32)((mask) << 16), (u32)((code) << 16), 2, #name "_" #type, type, name } -// two 16-bit values -#define ARMv7_OP4(mask0, mask1, code0, code1, type, name) { (u32)((mask0) << 16) | (mask1), (u32)((code0) << 16) | (code1), 4, #name "_" #type, type, name } - -static const ARMv7_opcode_t ARMv7_opcode_table[] = -{ - ARMv7_OP2(0xffff, 0x0000, T1, NULL_OP), // ??? - - ARMv7_OP4(0xffff, 0x0000, 0xf870, 0x0000, T1, HACK), // "Undefined" Thumb opcode - ARMv7_OP4(0x0ff0, 0x00f0, 0x0070, 0x0090, A1, HACK), // "Undefined" ARM opcode - - ARMv7_OP4(0xfbe0, 0x8000, 0xf140, 0x0000, T1, ADC_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x02a0, 0x0000, A1, ADC_IMM), - ARMv7_OP2(0xffc0, 0x4040, T1, ADC_REG), - ARMv7_OP4(0xffe0, 0x8000, 0xeb40, 0x0000, T2, ADC_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x00a0, 0x0000, A1, ADC_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x00a0, 0x0010, A1, ADC_RSR), - - ARMv7_OP2(0xf800, 0xa800, T1, ADD_SPI), - ARMv7_OP2(0xff80, 0xb000, T2, ADD_SPI), - ARMv7_OP4(0xfbef, 0x8000, 0xf10d, 0x0000, T3, ADD_SPI), - ARMv7_OP4(0xfbff, 0x8000, 0xf20d, 0x0000, T4, ADD_SPI), - ARMv7_OP4(0x0fef, 0x0000, 0x028d, 0x0000, A1, ADD_SPI), - ARMv7_OP2(0xff78, 0x4468, T1, ADD_SPR), - ARMv7_OP2(0xff87, 0x4485, T2, ADD_SPR), - ARMv7_OP4(0xffef, 0x8000, 0xeb0d, 0x0000, T3, ADD_SPR), - ARMv7_OP4(0x0fef, 0x0010, 0x008d, 0x0000, A1, ADD_SPR), - ARMv7_OP2(0xfe00, 0x1c00, T1, ADD_IMM), - ARMv7_OP2(0xf800, 0x3000, T2, ADD_IMM), - ARMv7_OP4(0xfbe0, 0x8000, 0xf100, 0x0000, T3, ADD_IMM), - ARMv7_OP4(0xfbf0, 0x8000, 0xf200, 0x0000, T4, ADD_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x0280, 0x0000, A1, ADD_IMM), - ARMv7_OP2(0xfe00, 0x1800, T1, ADD_REG), - ARMv7_OP2(0xff00, 0x4400, T2, ADD_REG), - ARMv7_OP4(0xffe0, 0x8000, 0xeb00, 0x0000, T3, ADD_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x0080, 0x0000, A1, ADD_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x0080, 0x0010, A1, ADD_RSR), - - ARMv7_OP2(0xf800, 0xa000, T1, ADR), - ARMv7_OP4(0xfbff, 0x8000, 0xf2af, 0x0000, T2, ADR), - ARMv7_OP4(0xfbff, 0x8000, 0xf20f, 0x0000, T3, ADR), - ARMv7_OP4(0x0fff, 0x0000, 0x028f, 0x0000, A1, ADR), - ARMv7_OP4(0x0fff, 0x0000, 0x024f, 0x0000, A2, ADR), - - ARMv7_OP4(0xfbe0, 0x8000, 0xf000, 0x0000, T1, AND_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x0200, 0x0000, A1, AND_IMM), - ARMv7_OP2(0xffc0, 0x4000, T1, AND_REG), - ARMv7_OP4(0xffe0, 0x8000, 0xea00, 0x0000, T2, AND_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x0000, 0x0000, A1, AND_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x0000, 0x0010, A1, AND_RSR), - - ARMv7_OP2(0xf800, 0x1000, T1, ASR_IMM), - ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0020, T2, ASR_IMM), - ARMv7_OP4(0x0fef, 0x0070, 0x01a0, 0x0040, A1, ASR_IMM), - ARMv7_OP2(0xffc0, 0x4100, T1, ASR_REG), - ARMv7_OP4(0xffe0, 0xf0f0, 0xfa40, 0xf000, T2, ASR_REG), - ARMv7_OP4(0x0fef, 0x00f0, 0x01a0, 0x0050, A1, ASR_REG), - - ARMv7_OP2(0xf000, 0xd000, T1, B), - ARMv7_OP2(0xf800, 0xe000, T2, B), - ARMv7_OP4(0xf800, 0xd000, 0xf000, 0x8000, T3, B), - ARMv7_OP4(0xf800, 0xd000, 0xf000, 0x9000, T4, B), - ARMv7_OP4(0x0f00, 0x0000, 0x0a00, 0x0000, A1, B), - - ARMv7_OP4(0xffff, 0x8020, 0xf36f, 0x0000, T1, BFC), - ARMv7_OP4(0x0fe0, 0x007f, 0x07c0, 0x001f, A1, BFC), - ARMv7_OP4(0xfff0, 0x8020, 0xf360, 0x0000, T1, BFI), - ARMv7_OP4(0x0fe0, 0x0070, 0x07c0, 0x0010, A1, BFI), - - ARMv7_OP4(0xfbe0, 0x8000, 0xf020, 0x0000, T1, BIC_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x03c0, 0x0000, A1, BIC_IMM), - ARMv7_OP2(0xffc0, 0x4380, T1, BIC_REG), - ARMv7_OP4(0xffe0, 0x8000, 0xea20, 0x0000, T2, BIC_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x01c0, 0x0000, A1, BIC_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x01c0, 0x0010, A1, BIC_RSR), - - ARMv7_OP2(0xff00, 0xbe00, T1, BKPT), - ARMv7_OP4(0x0ff0, 0x00f0, 0x0120, 0x0070, A1, BKPT), - - ARMv7_OP4(0xf800, 0xd000, 0xf000, 0xd000, T1, BL), - ARMv7_OP4(0x0f00, 0x0000, 0x0b00, 0x0000, A1, BL), - ARMv7_OP2(0xff80, 0x4780, T1, BLX), - ARMv7_OP4(0xf800, 0xc001, 0xf000, 0xc000, T2, BLX), - ARMv7_OP4(0x0fff, 0xfff0, 0x012f, 0xff30, A1, BLX), - ARMv7_OP4(0xfe00, 0x0000, 0xfa00, 0x0000, A2, BLX), - - ARMv7_OP2(0xff87, 0x4700, T1, BX), - ARMv7_OP4(0x0fff, 0xfff0, 0x012f, 0xff10, A1, BX), - - ARMv7_OP2(0xf500, 0xb100, T1, CB_Z), - - ARMv7_OP4(0xfff0, 0xf0f0, 0xfab0, 0xf080, T1, CLZ), - ARMv7_OP4(0x0fff, 0x0ff0, 0x016f, 0x0f10, A1, CLZ), - - ARMv7_OP4(0xfbf0, 0x8f00, 0xf110, 0x0f00, T1, CMN_IMM), - ARMv7_OP4(0x0ff0, 0xf000, 0x0370, 0x0000, A1, CMN_IMM), - ARMv7_OP2(0xffc0, 0x42c0, T1, CMN_REG), - ARMv7_OP4(0xfff0, 0x8f00, 0xeb10, 0x0f00, T2, CMN_REG), - ARMv7_OP4(0x0ff0, 0xf010, 0x0170, 0x0000, A1, CMN_REG), - ARMv7_OP4(0x0ff0, 0xf090, 0x0170, 0x0010, A1, CMN_RSR), - - ARMv7_OP2(0xf800, 0x2800, T1, CMP_IMM), - ARMv7_OP4(0xfbf0, 0x8f00, 0xf1b0, 0x0f00, T2, CMP_IMM), - ARMv7_OP4(0x0ff0, 0xf000, 0x0350, 0x0000, A1, CMP_IMM), - ARMv7_OP2(0xffc0, 0x4280, T1, CMP_REG), - ARMv7_OP2(0xff00, 0x4500, T2, CMP_REG), - ARMv7_OP4(0xfff0, 0x8f00, 0xebb0, 0x0f00, T3, CMP_REG), - ARMv7_OP4(0x0ff0, 0xf010, 0x0150, 0x0000, A1, CMP_REG), - ARMv7_OP4(0x0ff0, 0xf090, 0x0150, 0x0010, A1, CMP_RSR), - - ARMv7_OP4(0xfbe0, 0x8000, 0xf080, 0x0000, T1, EOR_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x0220, 0x0000, A1, EOR_IMM), - ARMv7_OP2(0xffc0, 0x4040, T1, EOR_REG), - ARMv7_OP4(0xffe0, 0x8000, 0xea80, 0x0000, T2, EOR_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x0020, 0x0000, A1, EOR_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x0020, 0x0010, A1, EOR_RSR), - - ARMv7_OP2(0xff00, 0xbf00, T1, IT), - - ARMv7_OP2(0xf800, 0xc800, T1, LDM), - ARMv7_OP4(0xffd0, 0x2000, 0xe890, 0x0000, T2, LDM), - ARMv7_OP4(0x0fd0, 0x0000, 0x0890, 0x0000, A1, LDM), - ARMv7_OP4(0x0fd0, 0x0000, 0x0810, 0x0000, A1, LDMDA), - ARMv7_OP4(0xffd0, 0x2000, 0xe910, 0x0000, T1, LDMDB), - ARMv7_OP4(0x0fd0, 0x0000, 0x0910, 0x0000, A1, LDMDB), - ARMv7_OP4(0x0fd0, 0x0000, 0x0990, 0x0000, A1, LDMIB), - - ARMv7_OP2(0xf800, 0x6800, T1, LDR_IMM), - ARMv7_OP2(0xf800, 0x9800, T2, LDR_IMM), - ARMv7_OP4(0xfff0, 0x0000, 0xf8d0, 0x0000, T3, LDR_IMM), - ARMv7_OP4(0xfff0, 0x0800, 0xf850, 0x0800, T4, LDR_IMM), - ARMv7_OP4(0x0e50, 0x0000, 0x0410, 0x0000, A1, LDR_IMM), - ARMv7_OP2(0xf800, 0x4800, T1, LDR_LIT), - ARMv7_OP4(0xff7f, 0x0000, 0xf85f, 0x0000, T2, LDR_LIT), - ARMv7_OP4(0x0f7f, 0x0000, 0x051f, 0x0000, A1, LDR_LIT), - ARMv7_OP2(0xfe00, 0x5800, T1, LDR_REG), - ARMv7_OP4(0xfff0, 0x0fc0, 0xf850, 0x0000, T2, LDR_REG), - ARMv7_OP4(0x0e50, 0x0010, 0x0610, 0x0000, A1, LDR_REG), - - ARMv7_OP2(0xf800, 0x7800, T1, LDRB_IMM), - ARMv7_OP4(0xfff0, 0x0000, 0xf890, 0x0000, T2, LDRB_IMM), - ARMv7_OP4(0xfff0, 0x0800, 0xf810, 0x0800, T3, LDRB_IMM), - ARMv7_OP4(0x0e50, 0x0000, 0x0450, 0x0000, A1, LDRB_IMM), - ARMv7_OP4(0xff7f, 0x0000, 0xf81f, 0x0000, T1, LDRB_LIT), - ARMv7_OP4(0x0f7f, 0x0000, 0x055f, 0x0000, A1, LDRB_LIT), - ARMv7_OP2(0xfe00, 0x5c00, T1, LDRB_REG), - ARMv7_OP4(0xfff0, 0x0fc0, 0xf810, 0x0000, T2, LDRB_REG), - ARMv7_OP4(0x0e50, 0x0010, 0x0650, 0x0000, A1, LDRB_REG), - - ARMv7_OP4(0xfe50, 0x0000, 0xe850, 0x0000, T1, LDRD_IMM), - ARMv7_OP4(0x0e50, 0x00f0, 0x0040, 0x00d0, A1, LDRD_IMM), - ARMv7_OP4(0xfe7f, 0x0000, 0xe85f, 0x0000, T1, LDRD_LIT), - ARMv7_OP4(0x0f7f, 0x00f0, 0x014f, 0x00d0, A1, LDRD_LIT), - ARMv7_OP4(0x0e50, 0x0ff0, 0x0000, 0x00d0, A1, LDRD_REG), - - ARMv7_OP4(0xfff0, 0x0000, 0xf990, 0x0000, T1, LDRSB_IMM), - ARMv7_OP4(0xfff0, 0x0800, 0xf910, 0x0800, T2, LDRSB_IMM), - ARMv7_OP4(0x0e50, 0x00f0, 0x0050, 0x00d0, A1, LDRSB_IMM), - ARMv7_OP4(0xff7f, 0x0000, 0xf91f, 0x0000, T1, LDRSB_LIT), - ARMv7_OP4(0x0f7f, 0x00f0, 0x015f, 0x00d0, A1, LDRSB_LIT), - ARMv7_OP2(0xfe00, 0x5600, T1, LDRSB_REG), - ARMv7_OP4(0xfff0, 0x0fc0, 0xf910, 0x0000, T2, LDRSB_REG), - ARMv7_OP4(0x0e50, 0x0ff0, 0x0010, 0x00d0, A1, LDRSB_REG), - - ARMv7_OP4(0xfff0, 0x0000, 0xf9b0, 0x0000, T1, LDRSH_IMM), - ARMv7_OP4(0xfff0, 0x0800, 0xf930, 0x0800, T2, LDRSH_IMM), - ARMv7_OP4(0x0e50, 0x00f0, 0x0050, 0x00f0, A1, LDRSH_IMM), - ARMv7_OP4(0xff7f, 0x0000, 0xf93f, 0x0000, T1, LDRSH_LIT), - ARMv7_OP4(0x0f7f, 0x00f0, 0x015f, 0x00f0, A1, LDRSH_LIT), - ARMv7_OP2(0xfe00, 0x5e00, T1, LDRSH_REG), - ARMv7_OP4(0xfff0, 0x0fc0, 0xf930, 0x0000, T2, LDRSH_REG), - ARMv7_OP4(0x0e50, 0x0ff0, 0x0010, 0x00f0, A1, LDRSH_REG), - - ARMv7_OP2(0xf800, 0x0000, T1, LSL_IMM), - ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0000, T2, LSL_IMM), - ARMv7_OP4(0x0fef, 0x0070, 0x01a0, 0x0000, A1, LSL_IMM), - ARMv7_OP2(0xffc0, 0x4080, T1, LSL_REG), - ARMv7_OP4(0xffe0, 0xf0f0, 0xfa00, 0xf000, T2, LSL_REG), - ARMv7_OP4(0x0fef, 0x00f0, 0x01a0, 0x0010, A1, LSL_REG), - - ARMv7_OP2(0xf800, 0x0800, T1, LSR_IMM), - ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0010, T2, LSR_IMM), - ARMv7_OP4(0x0fef, 0x0030, 0x01a0, 0x0020, A1, LSR_IMM), - ARMv7_OP2(0xffc0, 0x40c0, T1, LSR_REG), - ARMv7_OP4(0xffe0, 0xf0f0, 0xfa20, 0xf000, T2, LSR_REG), - ARMv7_OP4(0x0fef, 0x00f0, 0x01a0, 0x0030, A1, LSR_REG), - - ARMv7_OP4(0xfff0, 0x00f0, 0xfb00, 0x0000, T1, MLA), - ARMv7_OP4(0x0fe0, 0x00f0, 0x0020, 0x0090, A1, MLA), - - ARMv7_OP4(0xfff0, 0x00f0, 0xfb00, 0x0010, T1, MLS), - ARMv7_OP4(0x0ff0, 0x00f0, 0x0060, 0x0090, A1, MLS), - - ARMv7_OP2(0xf800, 0x2000, T1, MOV_IMM), - ARMv7_OP4(0xfbef, 0x8000, 0xf04f, 0x0000, T2, MOV_IMM), - ARMv7_OP4(0xfbf0, 0x8000, 0xf240, 0x0000, T3, MOV_IMM), - ARMv7_OP4(0x0fef, 0x0000, 0x03a0, 0x0000, A1, MOV_IMM), - ARMv7_OP4(0x0ff0, 0x0000, 0x0300, 0x0000, A2, MOV_IMM), - ARMv7_OP2(0xff00, 0x4600, T1, MOV_REG), - ARMv7_OP2(0xffc0, 0x0000, T2, MOV_REG), - ARMv7_OP4(0xffef, 0xf0f0, 0xea4f, 0x0000, T3, MOV_REG), - ARMv7_OP4(0x0fef, 0x0ff0, 0x01a0, 0x0000, A1, MOV_REG), - ARMv7_OP4(0xfbf0, 0x8000, 0xf2c0, 0x0000, T1, MOVT), - ARMv7_OP4(0x0ff0, 0x0000, 0x0340, 0x0000, A1, MOVT), - - ARMv7_OP4(0xffff, 0xf0ff, 0xf3ef, 0x8000, T1, MRS), - ARMv7_OP4(0x0fff, 0x0fff, 0x010f, 0x0000, A1, MRS), - ARMv7_OP4(0x0ff3, 0xf000, 0x0320, 0xf000, A1, MSR_IMM), - ARMv7_OP4(0xfff0, 0xf3ff, 0xf380, 0x8000, T1, MSR_REG), - ARMv7_OP4(0x0ff3, 0xfff0, 0x0120, 0xf000, A1, MSR_REG), - - ARMv7_OP2(0xffc0, 0x4340, T1, MUL), - ARMv7_OP4(0xfff0, 0xf0f0, 0xfb00, 0xf000, T2, MUL), - ARMv7_OP4(0x0fe0, 0xf0f0, 0x0000, 0x0090, A1, MUL), - - ARMv7_OP4(0xfbef, 0x8000, 0xf06f, 0x0000, T1, MVN_IMM), - ARMv7_OP4(0x0fef, 0x0000, 0x03e0, 0x0000, A1, MVN_IMM), - ARMv7_OP2(0xffc0, 0x43c0, T1, MVN_REG), - ARMv7_OP4(0xffef, 0x8000, 0xea6f, 0x0000, T2, MVN_REG), - ARMv7_OP4(0xffef, 0x0010, 0x01e0, 0x0000, A1, MVN_REG), - ARMv7_OP4(0x0fef, 0x0090, 0x01e0, 0x0010, A1, MVN_RSR), - - ARMv7_OP2(0xffff, 0xbf00, T1, NOP), - ARMv7_OP4(0xffff, 0xffff, 0xf3af, 0x8000, T2, NOP), - ARMv7_OP4(0x0fff, 0xffff, 0x0320, 0xf000, A1, NOP), - - ARMv7_OP4(0xfbe0, 0x8000, 0xf060, 0x0000, T1, ORN_IMM), - ARMv7_OP4(0xffe0, 0x8000, 0xea60, 0x0000, T1, ORN_REG), - - ARMv7_OP4(0xfbe0, 0x8000, 0xf040, 0x0000, T1, ORR_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x0380, 0x0000, A1, ORR_IMM), - ARMv7_OP2(0xffc0, 0x4300, T1, ORR_REG), - ARMv7_OP4(0xffe0, 0x8000, 0xea40, 0x0000, T2, ORR_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x0180, 0x0000, A1, ORR_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x0180, 0x0010, A1, ORR_RSR), - - ARMv7_OP4(0xfff0, 0x8010, 0xeac0, 0x0000, T1, PKH), - ARMv7_OP4(0x0ff0, 0x0030, 0x0680, 0x0010, A1, PKH), - - ARMv7_OP2(0xfe00, 0xbc00, T1, POP), - ARMv7_OP4(0xffff, 0x0000, 0xe8bd, 0x0000, T2, POP), - ARMv7_OP4(0xffff, 0x0fff, 0xf85d, 0x0b04, T3, POP), - ARMv7_OP4(0x0fff, 0x0000, 0x08bd, 0x0000, A1, POP), - ARMv7_OP4(0x0fff, 0x0fff, 0x049d, 0x0004, A2, POP), - - ARMv7_OP2(0xfe00, 0xb400, T1, PUSH), - ARMv7_OP4(0xffff, 0x0000, 0xe92d, 0x0000, T2, PUSH), // had an error in arch ref - ARMv7_OP4(0xffff, 0x0fff, 0xf84d, 0x0d04, T3, PUSH), - ARMv7_OP4(0x0fff, 0x0000, 0x092d, 0x0000, A1, PUSH), - ARMv7_OP4(0x0fff, 0x0fff, 0x052d, 0x0004, A2, PUSH), - - // TODO (Q*...) - - ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf0a0, T1, RBIT), - ARMv7_OP4(0x0fff, 0x0ff0, 0x06ff, 0x0f30, A1, RBIT), - - ARMv7_OP2(0xffc0, 0xba00, T1, REV), - ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf080, T2, REV), - ARMv7_OP4(0x0fff, 0x0ff0, 0x06bf, 0x0f30, A1, REV), - ARMv7_OP2(0xffc0, 0xba40, T1, REV16), - ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf090, T2, REV16), - ARMv7_OP4(0x0fff, 0x0ff0, 0x06bf, 0x0fb0, A1, REV16), - ARMv7_OP2(0xffc0, 0xbac0, T1, REVSH), - ARMv7_OP4(0xfff0, 0xf0f0, 0xfa90, 0xf0b0, T2, REVSH), - ARMv7_OP4(0x0fff, 0x0ff0, 0x06ff, 0x0fb0, A1, REVSH), - - ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0030, T1, ROR_IMM), - ARMv7_OP4(0x0fef, 0x0070, 0x01a0, 0x0060, A1, ROR_IMM), - ARMv7_OP2(0xffc0, 0x41c0, T1, ROR_REG), - ARMv7_OP4(0xffe0, 0xf0f0, 0xfa60, 0xf000, T2, ROR_REG), - ARMv7_OP4(0x0fef, 0x00f0, 0x01a0, 0x0070, A1, ROR_REG), - ARMv7_OP4(0xffef, 0xf0f0, 0xea4f, 0x0030, T1, RRX), - ARMv7_OP4(0x0fef, 0x0ff0, 0x01a0, 0x0060, A1, RRX), - - ARMv7_OP2(0xffc0, 0x4240, T1, RSB_IMM), - ARMv7_OP4(0xfbe0, 0x8000, 0xf1c0, 0x0000, T2, RSB_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x0260, 0x0000, A1, RSB_IMM), - ARMv7_OP4(0xffe0, 0x8000, 0xebc0, 0x0000, T1, RSB_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x0060, 0x0000, A1, RSB_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x0060, 0x0010, A1, RSB_RSR), - - ARMv7_OP4(0x0fe0, 0x0000, 0x02e0, 0x0000, A1, RSC_IMM), - ARMv7_OP4(0x0fe0, 0x0010, 0x00e0, 0x0000, A1, RSC_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x00e0, 0x0010, A1, RSC_RSR), - - // TODO (SADD16, SADD8, SASX) - - ARMv7_OP4(0xfbe0, 0x8000, 0xf160, 0x0000, T1, SBC_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x02c0, 0x0000, A1, SBC_IMM), - ARMv7_OP2(0xffc0, 0x4180, T1, SBC_REG), - ARMv7_OP4(0xffe0, 0x8000, 0xeb60, 0x0000, T2, SBC_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x00c0, 0x0000, A1, SBC_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x00c0, 0x0010, A1, SBC_RSR), - - ARMv7_OP4(0xfff0, 0x8020, 0xf340, 0x0000, T1, SBFX), - ARMv7_OP4(0x0fe0, 0x0070, 0x07a0, 0x0050, A1, SBFX), - - ARMv7_OP4(0xfff0, 0xf0f0, 0xfb90, 0xf0f0, T1, SDIV), // ??? - - ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf080, T1, SEL), - ARMv7_OP4(0x0ff0, 0x0ff0, 0x0680, 0x0fb0, A1, SEL), - - // TODO (SH*, SM*, SS*) - - ARMv7_OP2(0xf800, 0xc000, T1, STM), - ARMv7_OP4(0xffd0, 0xa000, 0xe880, 0x0000, T2, STM), - ARMv7_OP4(0x0fd0, 0x0000, 0x0880, 0x0000, A1, STM), - ARMv7_OP4(0x0fd0, 0x0000, 0x0800, 0x0000, A1, STMDA), - ARMv7_OP4(0xffd0, 0xa000, 0xe900, 0x0000, T1, STMDB), - ARMv7_OP4(0x0fd0, 0x0000, 0x0900, 0x0000, A1, STMDB), - ARMv7_OP4(0x0fd0, 0x0000, 0x0980, 0x0000, A1, STMIB), - - ARMv7_OP2(0xf800, 0x6000, T1, STR_IMM), - ARMv7_OP2(0xf800, 0x9000, T2, STR_IMM), - ARMv7_OP4(0xfff0, 0x0000, 0xf8c0, 0x0000, T3, STR_IMM), - ARMv7_OP4(0xfff0, 0x0800, 0xf840, 0x0800, T4, STR_IMM), - ARMv7_OP4(0x0e50, 0x0000, 0x0400, 0x0000, A1, STR_IMM), - ARMv7_OP2(0xfe00, 0x5000, T1, STR_REG), - ARMv7_OP4(0xfff0, 0x0fc0, 0xf840, 0x0000, T2, STR_REG), - ARMv7_OP4(0x0e50, 0x0010, 0x0600, 0x0000, A1, STR_REG), - - ARMv7_OP2(0xf800, 0x7000, T1, STRB_IMM), - ARMv7_OP4(0xfff0, 0x0000, 0xf880, 0x0000, T2, STRB_IMM), - ARMv7_OP4(0xfff0, 0x0800, 0xf800, 0x0800, T3, STRB_IMM), - ARMv7_OP4(0x0e50, 0x0000, 0x0440, 0x0000, A1, STRB_IMM), - ARMv7_OP2(0xfe00, 0x5400, T1, STRB_REG), - ARMv7_OP4(0xfff0, 0x0fc0, 0xf800, 0x0000, T2, STRB_REG), - ARMv7_OP4(0x0e50, 0x0010, 0x0640, 0x0000, A1, STRB_REG), - - ARMv7_OP4(0xfe50, 0x0000, 0xe840, 0x0000, T1, STRD_IMM), - ARMv7_OP4(0x0e50, 0x00f0, 0x0040, 0x00f0, A1, STRD_IMM), - ARMv7_OP4(0x0e50, 0x0ff0, 0x0000, 0x00f0, A1, STRD_REG), - - ARMv7_OP2(0xf800, 0x8000, T1, STRH_IMM), - ARMv7_OP4(0xfff0, 0x0000, 0xf8a0, 0x0000, T2, STRH_IMM), - ARMv7_OP4(0xfff0, 0x0800, 0xf820, 0x0800, T3, STRH_IMM), - ARMv7_OP4(0x0e50, 0x00f0, 0x0040, 0x00b0, A1, STRH_IMM), - ARMv7_OP2(0xfe00, 0x5200, T1, STRH_REG), - ARMv7_OP4(0xfff0, 0x0fc0, 0xf820, 0x0000, T2, STRH_REG), - ARMv7_OP4(0x0e50, 0x0ff0, 0x0000, 0x00b0, A1, STRH_REG), - - ARMv7_OP2(0xff80, 0xb080, T1, SUB_SPI), - ARMv7_OP4(0xfbef, 0x8000, 0xf1ad, 0x0000, T2, SUB_SPI), - ARMv7_OP4(0xfbff, 0x8000, 0xf2ad, 0x0000, T3, SUB_SPI), - ARMv7_OP4(0x0fef, 0x0000, 0x024d, 0x0000, A1, SUB_SPI), - ARMv7_OP4(0xffef, 0x8000, 0xebad, 0x0000, T1, SUB_SPR), - ARMv7_OP4(0x0fef, 0x0010, 0x004d, 0x0000, A1, SUB_SPR), - ARMv7_OP2(0xfe00, 0x1e00, T1, SUB_IMM), - ARMv7_OP2(0xf800, 0x3800, T2, SUB_IMM), - ARMv7_OP4(0xfbe0, 0x8000, 0xf1a0, 0x0000, T3, SUB_IMM), - ARMv7_OP4(0xfbf0, 0x8000, 0xf2a0, 0x0000, T4, SUB_IMM), - ARMv7_OP4(0x0fe0, 0x0000, 0x0240, 0x0000, A1, SUB_IMM), - ARMv7_OP2(0xfe00, 0x1a00, T1, SUB_REG), - ARMv7_OP4(0xffe0, 0x8000, 0xeba0, 0x0000, T2, SUB_REG), - ARMv7_OP4(0x0fe0, 0x0010, 0x0040, 0x0000, A1, SUB_REG), - ARMv7_OP4(0x0fe0, 0x0090, 0x0040, 0x0010, A1, SUB_RSR), - - ARMv7_OP2(0xff00, 0xdf00, T1, SVC), - ARMv7_OP4(0x0f00, 0x0000, 0x0f00, 0x0000, A1, SVC), - - // TODO (SX*) - - ARMv7_OP4(0xfff0, 0xffe0, 0xe8d0, 0xf000, T1, TB_), - - ARMv7_OP4(0xfbf0, 0x8f00, 0xf090, 0x0f00, T1, TEQ_IMM), - ARMv7_OP4(0x0ff0, 0xf000, 0x0330, 0x0000, A1, TEQ_IMM), - ARMv7_OP4(0xfff0, 0x8f00, 0xea90, 0x0f00, T1, TEQ_REG), - ARMv7_OP4(0x0ff0, 0xf010, 0x0130, 0x0000, A1, TEQ_REG), - ARMv7_OP4(0x0ff0, 0xf090, 0x0130, 0x0010, A1, TEQ_RSR), - - ARMv7_OP4(0xfbf0, 0x8f00, 0xf010, 0x0f00, T1, TST_IMM), - ARMv7_OP4(0x0ff0, 0xf000, 0x0310, 0x0000, A1, TST_IMM), - ARMv7_OP2(0xffc0, 0x4200, T1, TST_REG), - ARMv7_OP4(0xfff0, 0x8f00, 0xea10, 0x0f00, T2, TST_REG), - ARMv7_OP4(0x0ff0, 0xf010, 0x0110, 0x0000, A1, TST_REG), - ARMv7_OP4(0x0ff0, 0xf090, 0x0110, 0x0010, A1, TST_RSR) - - // TODO (U*, V*) -}; - -#undef ARMv7_OP2 -#undef ARMv7_OP4 diff --git a/rpcs3/Emu/ARMv7/ARMv7Opcodes.h b/rpcs3/Emu/ARMv7/ARMv7Opcodes.h index 2d079aa6f9..ed415bf2a2 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Opcodes.h +++ b/rpcs3/Emu/ARMv7/ARMv7Opcodes.h @@ -1,36 +1,25 @@ #pragma once - +#if 0 #include "Emu/ARMv7/ARMv7Thread.h" #include "Emu/ARMv7/ARMv7Interpreter.h" -#include "Emu/System.h" -#include "Utilities/Log.h" - -static const char* g_arm_reg_name[16] = -{ - "r0", "r1", "r2", "r3", - "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", - "r12", "sp", "lr", "pc", -}; using namespace ARMv7_instrs; struct ARMv7_Instruction { - void(*func)(ARMv7Thread* thr, const ARMv7_encoding type); + void(*func)(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); u8 size; ARMv7_encoding type; const char* name; }; - #define ARMv7_OP_2(func, type) { func, 2, type, #func "_" #type } #define ARMv7_OP_4(func, type) { func, 4, type, #func "_" #type } #define ARMv7_NULL_OP { NULL_OP, 2, T1, "NULL_OP" } // 0x1... -static void group_0x1(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x1(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x1_main[] = { @@ -56,7 +45,7 @@ static const ARMv7_Instruction g_table_0x1[] = { group_0x1 } }; -static void group_0x1(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x1(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x0e00) >> 8; @@ -69,7 +58,7 @@ static void group_0x1(ARMv7Thread* thr, const ARMv7_encoding type) } // 0x2... -static void group_0x2(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x2(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x2_main[] = { @@ -89,7 +78,7 @@ static const ARMv7_Instruction g_table_0x2[] = { group_0x2 } }; -static void group_0x2(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x2(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0800) >> 8; thr->m_last_instr_name = g_table_0x2_main[index].name; @@ -99,7 +88,7 @@ static void group_0x2(ARMv7Thread* thr, const ARMv7_encoding type) } // 0x3... -static void group_0x3(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x3(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x3_main[] = { @@ -119,7 +108,7 @@ static const ARMv7_Instruction g_table_0x3[] = { group_0x3 } }; -static void group_0x3(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x3(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0800) >> 8; thr->m_last_instr_name = g_table_0x3_main[index].name; @@ -129,13 +118,13 @@ static void group_0x3(ARMv7Thread* thr, const ARMv7_encoding type) } // 0x4... -static void group_0x4(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0x40(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0x41(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0x42(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0x43(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0x44(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0x47(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x4(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0x40(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0x41(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0x42(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0x43(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0x44(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0x47(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x4[] = { @@ -160,7 +149,7 @@ static const ARMv7_Instruction g_table_0x40[] = ARMv7_OP_2(LSR_REG, T1) // C 0xffc0 }; -static void group_0x40(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x40(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x00c0) >> 4; thr->m_last_instr_name = g_table_0x40[index].name; @@ -186,7 +175,7 @@ static const ARMv7_Instruction g_table_0x41[] = ARMv7_OP_2(ROR_REG, T1) // C 0xffc0 }; -static void group_0x41(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x41(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x00c0) >> 4; thr->m_last_instr_name = g_table_0x41[index].name; @@ -211,7 +200,7 @@ static const ARMv7_Instruction g_table_0x42[] = ARMv7_OP_2(CMN_REG, T1) // C 0xffc0 }; -static void group_0x42(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x42(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x00c0) >> 4; thr->m_last_instr_name = g_table_0x42[index].name; @@ -237,7 +226,7 @@ static const ARMv7_Instruction g_table_0x43[] = ARMv7_OP_2(MVN_REG, T1) // C 0xffc0 }; -static void group_0x43(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x43(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x00c0) >> 4; thr->m_last_instr_name = g_table_0x43[index].name; @@ -258,7 +247,7 @@ static const ARMv7_Instruction g_table_0x44[] = ARMv7_OP_2(ADD_SPR, T2) // 8 0xff87 }; -static void group_0x44(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x44(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x0080) >> 4; @@ -284,7 +273,7 @@ static const ARMv7_Instruction g_table_0x47[] = ARMv7_OP_2(BLX, T1) // 8 0xff80 }; -static void group_0x47(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x47(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0080) >> 4; thr->m_last_instr_name = g_table_0x47[index].name; @@ -306,7 +295,7 @@ static const ARMv7_Instruction g_table_0x4_main[] = ARMv7_OP_2(LDR_LIT, T1) // 8 0xf800 }; -static void group_0x4(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x4(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x0f00) >> 8; @@ -319,7 +308,7 @@ static void group_0x4(ARMv7Thread* thr, const ARMv7_encoding type) } // 0x5... -static void group_0x5(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x5(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x5_main[] = { @@ -345,7 +334,7 @@ static const ARMv7_Instruction g_table_0x5[] = { group_0x5 } }; -static void group_0x5(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x5(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0e00) >> 8; thr->m_last_instr_name = g_table_0x5_main[index].name; @@ -355,7 +344,7 @@ static void group_0x5(ARMv7Thread* thr, const ARMv7_encoding type) } // 0x6... -static void group_0x6(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x6(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x6_main[] = { @@ -375,7 +364,7 @@ static const ARMv7_Instruction g_table_0x6[] = { group_0x6 } }; -static void group_0x6(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x6(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0800) >> 8; thr->m_last_instr_name = g_table_0x6_main[index].name; @@ -385,7 +374,7 @@ static void group_0x6(ARMv7Thread* thr, const ARMv7_encoding type) } // 0x7... -static void group_0x7(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x7(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x7_main[] = { @@ -405,7 +394,7 @@ static const ARMv7_Instruction g_table_0x7[] = { group_0x7 } }; -static void group_0x7(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x7(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0800) >> 8; thr->m_last_instr_name = g_table_0x7_main[index].name; @@ -415,7 +404,7 @@ static void group_0x7(ARMv7Thread* thr, const ARMv7_encoding type) } // 0x8... -static void group_0x8(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x8_main[] = { @@ -427,7 +416,7 @@ static const ARMv7_Instruction g_table_0x8[] = { group_0x8 } }; -static void group_0x8(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0800) >> 8; thr->m_last_instr_name = g_table_0x8_main[index].name; @@ -437,7 +426,7 @@ static void group_0x8(ARMv7Thread* thr, const ARMv7_encoding type) } // 0x9... -static void group_0x9(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0x9(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0x9_main[] = { @@ -457,7 +446,7 @@ static const ARMv7_Instruction g_table_0x9[] = { group_0x9 } }; -static void group_0x9(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0x9(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0800) >> 8; thr->m_last_instr_name = g_table_0x9_main[index].name; @@ -467,7 +456,7 @@ static void group_0x9(ARMv7Thread* thr, const ARMv7_encoding type) } // 0xa... -static void group_0xa(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0xa(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0xa_main[] = { @@ -487,7 +476,7 @@ static const ARMv7_Instruction g_table_0xa[] = { group_0xa } }; -static void group_0xa(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xa(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x0800) >> 8; thr->m_last_instr_name = g_table_0xa_main[index].name; @@ -497,9 +486,9 @@ static void group_0xa(ARMv7Thread* thr, const ARMv7_encoding type) } // 0xb... -static void group_0xb(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xb0(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xba(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0xb(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xb0(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xba(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0xb0[] = { @@ -514,7 +503,7 @@ static const ARMv7_Instruction g_table_0xb0[] = ARMv7_OP_2(SUB_SPI, T1) // 8 0xff80 }; -static void group_0xb0(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xb0(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0080) >> 4; thr->m_last_instr_name = g_table_0xb0[index].name; @@ -540,7 +529,7 @@ static const ARMv7_Instruction g_table_0xba[] = ARMv7_OP_2(REVSH, T1) // C 0xffc0 }; -static void group_0xba(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xba(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x00c0) >> 4; // mask 0xffc0 thr->m_last_instr_name = g_table_0xba[index].name; @@ -575,7 +564,7 @@ static const ARMv7_Instruction g_table_0xb[] = { group_0xb } }; -static void group_0xb(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xb(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x0e00) >> 8; @@ -591,7 +580,7 @@ static void group_0xb(ARMv7Thread* thr, const ARMv7_encoding type) } // 0xc... -static void group_0xc(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0xc(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0xc_main[] = { @@ -611,7 +600,7 @@ static const ARMv7_Instruction g_table_0xc[] = { group_0xc } }; -static void group_0xc(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xc(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x0800) >> 8; thr->m_last_instr_name = g_table_0xc_main[index].name; @@ -621,7 +610,7 @@ static void group_0xc(ARMv7Thread* thr, const ARMv7_encoding type) } // 0xd... -static void group_0xd(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0xd(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0xd_main[] = { @@ -648,7 +637,7 @@ static const ARMv7_Instruction g_table_0xd[] = { group_0xd } }; -static void group_0xd(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xd(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { //u32 index = (thr->code.code0 & 0x0f00) >> 8; //if ((thr->code.code0 & 0xf000) == 0xd000) index = 0; @@ -661,19 +650,19 @@ static void group_0xd(ARMv7Thread* thr, const ARMv7_encoding type) } // 0xe... -static void group_0xe(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xe85(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xe8(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xe9(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xea(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xea4(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xea4f(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xea4f0000(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xea4f0030(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xea6(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xeb(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xeb0(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xeba(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0xe(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xe85(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xe8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xe9(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xea(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xea4(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xea4f(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xea4f0000(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xea4f0030(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xea6(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xeb(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xeb0(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xeba(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0xe85[] = @@ -696,7 +685,7 @@ static const ARMv7_Instruction g_table_0xe85[] = ARMv7_OP_4(LDRD_LIT, T1) // F 0xfe7f, 0x0000 }; -static void group_0xe85(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xe85(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { //u32 index = thr->code.code0 & 0x000f; //if ((thr->code.code0 & 0xfe50) == 0xe850) index = 0x0; @@ -726,7 +715,7 @@ static const ARMv7_Instruction g_table_0xe8[] = ARMv7_OP_4(TB_, T1) // D 0xfff0, 0xffe0 }; -static void group_0xe8(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xe8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x00f0) >> 4; @@ -747,7 +736,7 @@ static const ARMv7_Instruction g_table_0xe9[] = ARMv7_OP_4(PUSH, T2) // 2 0xffff, 0x0000 }; -static void group_0xe9(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xe9(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x00d0) >> 4; @@ -779,7 +768,7 @@ static const ARMv7_Instruction g_table_0xea4[] = { group_0xea4f } // F }; -static void group_0xea4(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xea4(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = 0x0; if ((thr->code.code0 & 0xffef) == 0xea4f) index = 0xf; // check me @@ -798,7 +787,7 @@ static const ARMv7_Instruction g_table_0xea4f[] = { group_0xea4f0030 } // 3 }; -static void group_0xea4f(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xea4f(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code1 & 0x0030) >> 4; thr->m_last_instr_name = g_table_0xea4f[index].name; @@ -813,7 +802,7 @@ static const ARMv7_Instruction g_table_0xea4f0000[] = ARMv7_OP_4(LSL_IMM, T2) // 1 0xffef, 0x8030 }; -static void group_0xea4f0000(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xea4f0000(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = thr->code.code1 & 0x8030 ? 0x0 : 0x1; thr->m_last_instr_name = g_table_0xea4f0000[index].name; @@ -828,7 +817,7 @@ static const ARMv7_Instruction g_table_0xea4f0030[] = ARMv7_OP_4(ROR_IMM, T1) // 2 0xffef, 0x8030 }; -static void group_0xea4f0030(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xea4f0030(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = thr->code.code1 & 0x8030 ? 0x0 : 0x1; thr->m_last_instr_name = g_table_0xea4f0030[index].name; @@ -857,7 +846,7 @@ static const ARMv7_Instruction g_table_0xea6[] = ARMv7_OP_4(MVN_REG, T2) // F 0xffef, 0x8000 }; -static void group_0xea6(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xea6(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -886,7 +875,7 @@ static const ARMv7_Instruction g_table_0xea[] = ARMv7_OP_4(PKH, T1) // C 0xfff0, 0x8010 }; -static void group_0xea(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xea(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x00e0) >> 4; @@ -918,7 +907,7 @@ static const ARMv7_Instruction g_table_0xeb0[] = ARMv7_OP_4(ADD_SPR, T3) // D 0xffef, 0x8000 }; -static void group_0xeb0(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xeb0(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -948,7 +937,7 @@ static const ARMv7_Instruction g_table_0xeba[] = ARMv7_OP_4(SUB_SPR, T1) // D 0xffef, 0x8000 }; -static void group_0xeba(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xeba(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -977,7 +966,7 @@ static const ARMv7_Instruction g_table_0xeb[] = ARMv7_OP_4(RSB_REG, T1) // C 0xffe0, 0x8000 }; -static void group_0xeb(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xeb(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x00e0) >> 4; @@ -1015,7 +1004,7 @@ static const ARMv7_Instruction g_table_0xe[] = { group_0xe } }; -static void group_0xe(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xe(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x0f00) >> 8; @@ -1028,36 +1017,36 @@ static void group_0xe(ARMv7Thread* thr, const ARMv7_encoding type) } // 0xf... -static void group_0xf(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf000(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf04(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf06(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf0(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf1(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf1a(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf10(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf20(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf2a(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf2(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf36(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf3(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf810(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf800(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf81(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf820(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf840(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf84(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf850(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf85(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf8(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf910(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf91(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf930(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf93(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xf9(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xfa00(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xfa90(ARMv7Thread* thr, const ARMv7_encoding type); -static void group_0xfa(ARMv7Thread* thr, const ARMv7_encoding type); +static void group_0xf(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf000(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf04(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf06(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf0(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf1(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf1a(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf10(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf20(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf2a(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf2(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf36(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf3(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf810(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf800(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf81(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf820(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf840(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf84(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf850(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf85(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf910(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf91(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf930(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf93(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xf9(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xfa00(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xfa90(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); +static void group_0xfa(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type); static const ARMv7_Instruction g_table_0xf000[] = { @@ -1077,7 +1066,7 @@ static const ARMv7_Instruction g_table_0xf000[] = ARMv7_OP_4(BL, T1) // D 0xf800, 0xd000 }; -static void group_0xf000(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf000(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code1 & 0xd000) >> 12; @@ -1110,7 +1099,7 @@ static const ARMv7_Instruction g_table_0xf04[] = ARMv7_OP_4(MOV_IMM, T2) // F 0xfbef, 0x8000 }; -static void group_0xf04(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf04(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1142,7 +1131,7 @@ static const ARMv7_Instruction g_table_0xf06[] = ARMv7_OP_4(MVN_IMM, T1) // F 0xfbef, 0x8000 }; -static void group_0xf06(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf06(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1194,7 +1183,7 @@ static const ARMv7_Instruction g_table_0xf0[] = }; -static void group_0xf0(ARMv7Thread* thr, const ARMv7_encoding type) // TODO: optimize this group +static void group_0xf0(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) // TODO: optimize this group { u32 index = 0; if ((thr->m_arg & 0xfbe08000) == 0xf0000000) index = 0x0; @@ -1242,7 +1231,7 @@ static const ARMv7_Instruction g_table_0xf10[] = ARMv7_OP_4(ADD_SPI, T3) // D 0xfbef, 0x8000 }; -static void group_0xf10(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf10(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1272,7 +1261,7 @@ static const ARMv7_Instruction g_table_0xf1a[] = ARMv7_OP_4(SUB_SPI, T2) // D 0xfbef, 0x8000 }; -static void group_0xf1a(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf1a(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1301,7 +1290,7 @@ static const ARMv7_Instruction g_table_0xf1[] = ARMv7_OP_4(RSB_IMM, T2) // C 0xfbe0, 0x8000 }; -static void group_0xf1(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf1(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x00e0) >> 4; @@ -1334,7 +1323,7 @@ static const ARMv7_Instruction g_table_0xf20[] = ARMv7_OP_4(ADR, T3) // F 0xfbff, 0x8000 }; -static void group_0xf20(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf20(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1366,7 +1355,7 @@ static const ARMv7_Instruction g_table_0xf2a[] = ARMv7_OP_4(ADR, T2) // F 0xfbff, 0x8000 }; -static void group_0xf2a(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf2a(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1395,7 +1384,7 @@ static const ARMv7_Instruction g_table_0xf2[] = ARMv7_OP_4(MOVT, T1) // C 0xfbf0, 0x8000 }; -static void group_0xf2(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf2(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x00f0) >> 4; // mask 0xfbf0 thr->m_last_instr_name = g_table_0xf2[index].name; @@ -1424,7 +1413,7 @@ static const ARMv7_Instruction g_table_0xf36[] = ARMv7_OP_4(BFC, T1) // F 0xffff, 0x8020 }; -static void group_0xf36(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf36(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1455,7 +1444,7 @@ static const ARMv7_Instruction g_table_0xf3[] = ARMv7_OP_4(MRS, T1), // E 0xffff, 0xf0ff }; -static void group_0xf3(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf3(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x00f0) >> 4; thr->m_last_instr_name = g_table_0xf3[index].name; @@ -1477,7 +1466,7 @@ static const ARMv7_Instruction g_table_0xf800[] = ARMv7_OP_4(STRB_IMM, T3) // 8 0xfff0, 0x0800 }; -static void group_0xf800(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf800(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code1 & 0x0f00) >> 8; @@ -1502,7 +1491,7 @@ static const ARMv7_Instruction g_table_0xf810[] = ARMv7_OP_4(LDRB_IMM, T3) // 8 0xfff0, 0x0800 }; -static void group_0xf810(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf810(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code1 & 0x0f00) >> 8; @@ -1534,7 +1523,7 @@ static const ARMv7_Instruction g_table_0xf81[] = ARMv7_OP_4(LDRB_LIT, T1) // F 0xff7f, 0x0000 }; -static void group_0xf81(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf81(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1559,7 +1548,7 @@ static const ARMv7_Instruction g_table_0xf820[] = ARMv7_OP_4(STRH_IMM, T3) // 8 0xfff0, 0x0800 }; -static void group_0xf820(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf820(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code1 & 0x0f00) >> 8; @@ -1584,7 +1573,7 @@ static const ARMv7_Instruction g_table_0xf840[] = ARMv7_OP_4(STR_IMM, T4) // 8 0xfff0, 0x0800 }; -static void group_0xf840(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf840(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code1 & 0x0f00) >> 8; @@ -1614,7 +1603,7 @@ static const ARMv7_Instruction g_table_0xf84[] = ARMv7_OP_4(PUSH, T3) // D 0xffff, 0x0fff }; -static void group_0xf84(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf84(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1639,7 +1628,7 @@ static const ARMv7_Instruction g_table_0xf850[] = ARMv7_OP_4(LDR_IMM, T4) // 8 0xfff0, 0x0800 }; -static void group_0xf850(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf850(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code1 & 0x0f00) >> 8; @@ -1671,7 +1660,7 @@ static const ARMv7_Instruction g_table_0xf85[] = ARMv7_OP_4(LDR_LIT, T2) // F 0xff7f, 0x0000 }; -static void group_0xf85(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf85(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1701,7 +1690,7 @@ static const ARMv7_Instruction g_table_0xf8[] = ARMv7_OP_4(LDR_IMM, T3) // D 0xfff0, 0x0000 }; -static void group_0xf8(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf8(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code0 & 0x00f0) >> 4; thr->m_last_instr_name = g_table_0xf8[index].name; @@ -1723,7 +1712,7 @@ static const ARMv7_Instruction g_table_0xf910[] = ARMv7_OP_4(LDRSB_IMM, T2) // 8 0xfff0, 0x0800 }; -static void group_0xf910(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf910(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code1 & 0x0f00) >> 8; @@ -1755,7 +1744,7 @@ static const ARMv7_Instruction g_table_0xf91[] = ARMv7_OP_4(LDRSB_LIT, T1) // F 0xff7f, 0x0000 }; -static void group_0xf91(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf91(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1780,7 +1769,7 @@ static const ARMv7_Instruction g_table_0xf930[] = ARMv7_OP_4(LDRSH_IMM, T2) // 8 0xfff0, 0x0800 }; -static void group_0xf930(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf930(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code1 & 0x0f00) >> 8; @@ -1812,7 +1801,7 @@ static const ARMv7_Instruction g_table_0xf93[] = ARMv7_OP_4(LDRSH_LIT, T1) // F 0xff7f, 0x0000 }; -static void group_0xf93(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf93(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = thr->code.code0 & 0x000f; @@ -1840,7 +1829,7 @@ static const ARMv7_Instruction g_table_0xf9[] = ARMv7_OP_4(LDRSH_IMM, T1), // B 0xfff0, 0x0000 }; -static void group_0xf9(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf9(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x00f0) >> 4; @@ -1873,7 +1862,7 @@ static const ARMv7_Instruction g_table_0xfa00[] = ARMv7_OP_4(LSL_REG, T2) // F 0xffe0, 0xf0f0 }; -static void group_0xfa00(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xfa00(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code1 & 0xf0f0) == 0xf000 ? 0xf : 0x0; thr->m_last_instr_name = g_table_0xfa00[index].name; @@ -1898,7 +1887,7 @@ static const ARMv7_Instruction g_table_0xfa90[] = ARMv7_OP_4(REVSH, T2) // B 0xfff0, 0xf0f0 }; -static void group_0xfa90(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xfa90(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { const u32 index = (thr->code.code1 & 0x00f0) >> 4; thr->m_last_instr_name = g_table_0xfa90[index].name; @@ -1923,7 +1912,7 @@ static const ARMv7_Instruction g_table_0xfa[] = ARMv7_OP_4(CLZ, T1) // B 0xfff0, 0xf0f0 }; -static void group_0xfa(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xfa(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x00e0) >> 4; @@ -1958,7 +1947,7 @@ static const ARMv7_Instruction g_table_0xf_main[] = }; -static void group_0xf(ARMv7Thread* thr, const ARMv7_encoding type) +static void group_0xf(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type) { u32 index = (thr->code.code0 & 0x0b00) >> 8; @@ -2023,3 +2012,4 @@ static void execute_main_group(ARMv7Thread* thr) #undef ARMv7_OP_2 #undef ARMv7_OP_4 #undef ARMv7_NULL_OP +#endif diff --git a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp index c8a9e7c4b5..e4b1d65291 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Thread.cpp +++ b/rpcs3/Emu/ARMv7/ARMv7Thread.cpp @@ -10,22 +10,48 @@ #include "ARMv7DisAsm.h" #include "ARMv7Interpreter.h" +void ARMv7Context::write_pc(u32 value) +{ + thread.SetBranch(value); +} + +u32 ARMv7Context::read_pc() +{ + return thread.PC; +} + +void ARMv7Context::put_stack_arg(u32 shift, u32 value) +{ + vm::psv::write32(SP + shift, value); +} + +u32 ARMv7Context::get_stack_arg(u32 pos) +{ + return vm::psv::read32(SP + sizeof(u32) * (pos - 5)); +} + +void ARMv7Context::fast_call(u32 addr) +{ + return thread.FastCall(addr); +} + ARMv7Thread::ARMv7Thread() : CPUThread(CPU_THREAD_ARMv7) - , m_arg(0) - , m_last_instr_size(0) - , m_last_instr_name("UNK") + , context(*this) + //, m_arg(0) + //, m_last_instr_size(0) + //, m_last_instr_name("UNK") { } void ARMv7Thread::InitRegs() { - memset(GPR, 0, sizeof(GPR[0]) * 15); - APSR.APSR = 0; - IPSR.IPSR = 0; - ISET = Thumb; - ITSTATE.IT = 0; - SP = m_stack_addr + m_stack_size; + memset(context.GPR, 0, sizeof(context.GPR[0]) * 15); + context.APSR.APSR = 0; + context.IPSR.IPSR = 0; + context.ISET = Thumb; + context.ITSTATE.IT = 0; + context.SP = m_stack_addr + m_stack_size; } void ARMv7Thread::InitStack() @@ -37,26 +63,21 @@ void ARMv7Thread::InitStack() } } -u32 ARMv7Thread::GetStackArg(u32 pos) -{ - return vm::psv::read32(SP + sizeof(u32) * (pos - 5)); -} - std::string ARMv7Thread::RegsToString() { std::string result = "Registers:\n=========\n"; for(int i=0; i<15; ++i) { - result += fmt::Format("%s\t= 0x%08x\n", g_arm_reg_name[i], GPR[i]); + result += fmt::Format("%s\t= 0x%08x\n", g_arm_reg_name[i], context.GPR[i]); } result += fmt::Format("APSR\t= 0x%08x [N: %d, Z: %d, C: %d, V: %d, Q: %d]\n", - APSR.APSR, - fmt::by_value(APSR.N), - fmt::by_value(APSR.Z), - fmt::by_value(APSR.C), - fmt::by_value(APSR.V), - fmt::by_value(APSR.Q)); + context.APSR.APSR, + fmt::by_value(context.APSR.N), + fmt::by_value(context.APSR.Z), + fmt::by_value(context.APSR.C), + fmt::by_value(context.APSR.V), + fmt::by_value(context.APSR.Q)); return result; } @@ -85,7 +106,7 @@ void ARMv7Thread::DoRun() case 1: case 2: - m_dec = new ARMv7Decoder(*this); + m_dec = new ARMv7Decoder(context); break; } } @@ -110,21 +131,21 @@ void ARMv7Thread::FastCall(u32 addr) { auto old_status = m_status; auto old_PC = PC; - auto old_stack = SP; - auto old_LR = LR; + auto old_stack = context.SP; + auto old_LR = context.LR; auto old_thread = GetCurrentNamedThread(); m_status = Running; PC = addr; - LR = Emu.GetCPUThreadStop(); + context.LR = Emu.GetCPUThreadStop(); SetCurrentNamedThread(this); CPUThread::Task(); m_status = old_status; PC = old_PC; - SP = old_stack; - LR = old_LR; + context.SP = old_stack; + context.LR = old_LR; SetCurrentNamedThread(old_thread); } diff --git a/rpcs3/Emu/ARMv7/ARMv7Thread.h b/rpcs3/Emu/ARMv7/ARMv7Thread.h index 22e655188d..2dd26772e7 100644 --- a/rpcs3/Emu/ARMv7/ARMv7Thread.h +++ b/rpcs3/Emu/ARMv7/ARMv7Thread.h @@ -1,147 +1,24 @@ #pragma once #include "Emu/CPU/CPUThread.h" #include "Emu/Memory/Memory.h" - -enum ARMv7InstructionSet -{ - ARM, - Thumb, - Jazelle, - ThumbEE -}; +#include "ARMv7Context.h" class ARMv7Thread : public CPUThread { public: - u32 m_arg; - u8 m_last_instr_size; - const char* m_last_instr_name; + ARMv7Context context; + //u32 m_arg; + //u8 m_last_instr_size; + //const char* m_last_instr_name; ARMv7Thread(); - union - { - u32 GPR[15]; - - struct - { - u32 pad[13]; - - union - { - u32 SP; - - struct { u16 SP_main, SP_process; }; - }; - - u32 LR; - }; - }; - - union - { - struct - { - u32 N : 1; //Negative condition code flag - u32 Z : 1; //Zero condition code flag - u32 C : 1; //Carry condition code flag - u32 V : 1; //Overflow condition code flag - u32 Q : 1; //Set to 1 if an SSAT or USAT instruction changes (saturates) the input value for the signed or unsigned range of the result - u32 : 27; - }; - - u32 APSR; - - } APSR; - - union - { - struct - { - u32 : 24; - u32 exception : 8; - }; - - u32 IPSR; - - } IPSR; - - union - { - struct - { - u32 code1 : 16; - u32 code0 : 16; - }; - - u32 data; - - } code; - - ARMv7InstructionSet ISET; - - union - { - struct - { - u8 cond : 3; - u8 state : 5; - }; - - u8 IT; - - u32 advance() - { - const u32 res = (state & 0xf) ? (cond << 1 | state >> 4) : 0xe /* true */; - - state <<= 1; - if ((state & 0xf) == 0) // if no d - { - IT = 0; // clear ITSTATE - } - - return res; - } - - operator bool() const - { - return (state & 0xf) != 0; - } - - } ITSTATE; - - void write_gpr(u32 n, u32 value) - { - assert(n < 16); - - if(n < 15) - { - GPR[n] = value; - } - else - { - SetBranch(value & ~1); - } - } - - u32 read_gpr(u32 n) - { - assert(n < 16); - - if(n < 15) - { - return GPR[n]; - } - - return PC; - } - - void update_code(const u32 address) - { - code.code0 = vm::psv::read16(address & ~1); - code.code1 = vm::psv::read16(address + 2 & ~1); - m_arg = address & 0x1 ? code.code1 << 16 | code.code0 : code.data; - } + //void update_code(const u32 address) + //{ + // code.code0 = vm::psv::read16(address & ~1); + // code.code1 = vm::psv::read16(address + 2 & ~1); + // m_arg = address & 0x1 ? code.code1 << 16 | code.code0 : code.data; + //} public: virtual void InitRegs(); @@ -209,131 +86,3 @@ public: return *this; } }; - -template::value> -struct cast_armv7_gpr -{ - static_assert(is_enum, "Invalid type for cast_armv7_gpr"); - - typedef typename std::underlying_type::type underlying_type; - - __forceinline static u32 to_gpr(const T& value) - { - return cast_armv7_gpr::to_gpr(static_cast(value)); - } - - __forceinline static T from_gpr(const u32 reg) - { - return static_cast(cast_armv7_gpr::from_gpr(reg)); - } -}; - -template<> -struct cast_armv7_gpr -{ - __forceinline static u32 to_gpr(const u8& value) - { - return value; - } - - __forceinline static u8 from_gpr(const u32 reg) - { - return static_cast(reg); - } -}; - -template<> -struct cast_armv7_gpr -{ - __forceinline static u32 to_gpr(const u16& value) - { - return value; - } - - __forceinline static u16 from_gpr(const u32 reg) - { - return static_cast(reg); - } -}; - -template<> -struct cast_armv7_gpr -{ - __forceinline static u32 to_gpr(const u32& value) - { - return value; - } - - __forceinline static u32 from_gpr(const u32 reg) - { - return reg; - } -}; - -template<> -struct cast_armv7_gpr -{ - __forceinline static u32 to_gpr(const s8& value) - { - return value; - } - - __forceinline static s8 from_gpr(const u32 reg) - { - return static_cast(reg); - } -}; - -template<> -struct cast_armv7_gpr -{ - __forceinline static u32 to_gpr(const s16& value) - { - return value; - } - - __forceinline static s16 from_gpr(const u32 reg) - { - return static_cast(reg); - } -}; - -template<> -struct cast_armv7_gpr -{ - __forceinline static u32 to_gpr(const s32& value) - { - return value; - } - - __forceinline static s32 from_gpr(const u32 reg) - { - return static_cast(reg); - } -}; - -template<> -struct cast_armv7_gpr -{ - __forceinline static u32 to_gpr(const bool& value) - { - return value; - } - - __forceinline static bool from_gpr(const u32 reg) - { - return reinterpret_cast(reg); - } -}; - -template -__forceinline u32 cast_to_armv7_gpr(const T& value) -{ - return cast_armv7_gpr::to_gpr(value); -} - -template -__forceinline T cast_from_armv7_gpr(const u32 reg) -{ - return cast_armv7_gpr::from_gpr(reg); -} diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp index 7ae9f6a2a6..73a6f864e3 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp @@ -1,9 +1,10 @@ #include "stdafx.h" #include "Emu/System.h" #include "Emu/Memory/Memory.h" +#include "Emu/ARMv7/PSVFuncList.h" + #include "Emu/CPU/CPUThreadManager.h" #include "Emu/ARMv7/ARMv7Thread.h" -#include "Emu/ARMv7/PSVFuncList.h" extern psv_log_base sceLibKernel; @@ -86,7 +87,7 @@ struct SceKernelSystemInfo #pragma pack(pop) -s32 sceKernelCreateThread( +u32 sceKernelCreateThread( vm::psv::ptr pName, vm::psv::ptr entry, s32 initPriority, @@ -100,24 +101,21 @@ s32 sceKernelCreateThread( ARMv7Thread& new_thread = static_cast(Emu.GetCPU().AddThread(CPU_THREAD_ARMv7)); - u32 id = new_thread.GetId(); + const auto id = new_thread.GetId(); new_thread.SetEntry(entry.addr() ^ 1); new_thread.SetPrio(initPriority); new_thread.SetStackSize(stackSize); new_thread.SetName(pName.get_ptr()); - sceLibKernel.Error("*** New ARMv7 Thread [%s] (entry=0x%x)^1: id = %d", pName.get_ptr(), entry, id); + sceLibKernel.Error("*** New ARMv7 Thread [%s] (entry=0x%x)^1: id -> 0x%x", pName.get_ptr(), entry, id); new_thread.Run(); - - Emu.Pause(); - return id; } -s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::psv::ptr pArgBlock) +s32 sceKernelStartThread(u32 threadId, u32 argSize, vm::psv::ptr pArgBlock) { - sceLibKernel.Error("sceKernelStartThread(threadId=%d, argSize=%d, pArgBlock=0x%x)", threadId, argSize, pArgBlock); + sceLibKernel.Error("sceKernelStartThread(threadId=0x%x, argSize=0x%x, pArgBlock=0x%x)", threadId, argSize, pArgBlock); std::shared_ptr t = Emu.GetCPU().GetThread(threadId); @@ -129,30 +127,30 @@ s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::psv::ptr pAr ARMv7Thread& thread = static_cast(*t); // push arg block onto the stack - const u32 pos = (thread.SP -= argSize); + const u32 pos = (thread.context.SP -= argSize); memcpy(vm::get_ptr(pos), pArgBlock.get_ptr(), argSize); // set SceKernelThreadEntry function arguments - thread.write_gpr(0, argSize); - thread.write_gpr(1, pos); + thread.context.GPR[0] = argSize; + thread.context.GPR[1] = pos; thread.Exec(); return SCE_OK; } -s32 sceKernelExitThread(ARMv7Thread& CPU, s32 exitStatus) +s32 sceKernelExitThread(ARMv7Context& context, s32 exitStatus) { sceLibKernel.Error("sceKernelExitThread(exitStatus=0x%x)", exitStatus); // exit status is stored in r0 - CPU.Stop(); + context.thread.Stop(); return SCE_OK; } -s32 sceKernelDeleteThread(s32 threadId) +s32 sceKernelDeleteThread(u32 threadId) { - sceLibKernel.Todo("sceKernelDeleteThread(threadId=%d)", threadId); + sceLibKernel.Todo("sceKernelDeleteThread(threadId=0x%x)", threadId); return SCE_OK; } @@ -164,21 +162,21 @@ s32 sceKernelExitDeleteThread(s32 exitStatus) return SCE_OK; } -s32 sceKernelChangeThreadCpuAffinityMask(s32 threadId, s32 cpuAffinityMask) +s32 sceKernelChangeThreadCpuAffinityMask(u32 threadId, s32 cpuAffinityMask) { - sceLibKernel.Todo("sceKernelChangeThreadCpuAffinityMask(threadId=%d, cpuAffinityMask=0x%x)", threadId, cpuAffinityMask); + sceLibKernel.Todo("sceKernelChangeThreadCpuAffinityMask(threadId=0x%x, cpuAffinityMask=0x%x)", threadId, cpuAffinityMask); return SCE_OK; } -s32 sceKernelGetThreadCpuAffinityMask(s32 threadId) +s32 sceKernelGetThreadCpuAffinityMask(u32 threadId) { sceLibKernel.Todo("sceKernelGetThreadCpuAffinityMask(threadId=0x%x)", threadId); return SCE_OK; } -s32 sceKernelChangeThreadPriority(s32 threadId, s32 priority) +s32 sceKernelChangeThreadPriority(u32 threadId, s32 priority) { sceLibKernel.Todo("sceKernelChangeThreadPriority(threadId=0x%x, priority=%d)", threadId, priority); @@ -192,11 +190,11 @@ s32 sceKernelGetThreadCurrentPriority() return SCE_OK; } -s32 sceKernelGetThreadId() +u32 sceKernelGetThreadId(ARMv7Context& context) { - sceLibKernel.Todo("sceKernelGetThreadId()"); + sceLibKernel.Log("sceKernelGetThreadId()"); - return SCE_OK; + return context.thread.GetId(); } s32 sceKernelChangeCurrentThreadAttr(u32 clearAttr, u32 setAttr) @@ -206,9 +204,9 @@ s32 sceKernelChangeCurrentThreadAttr(u32 clearAttr, u32 setAttr) return SCE_OK; } -s32 sceKernelGetThreadExitStatus(s32 threadId, vm::psv::ptr pExitStatus) +s32 sceKernelGetThreadExitStatus(u32 threadId, vm::psv::ptr pExitStatus) { - sceLibKernel.Todo("sceKernelGetThreadExitStatus(threadId=%d, pExitStatus=0x%x)", threadId, pExitStatus); + sceLibKernel.Todo("sceKernelGetThreadExitStatus(threadId=0x%x, pExitStatus=0x%x)", threadId, pExitStatus); return SCE_OK; } @@ -227,9 +225,9 @@ s32 sceKernelCheckWaitableStatus() return SCE_OK; } -s32 sceKernelGetThreadInfo(s32 threadId, vm::psv::ptr pInfo) +s32 sceKernelGetThreadInfo(u32 threadId, vm::psv::ptr pInfo) { - sceLibKernel.Todo("sceKernelGetThreadInfo(threadId=%d, pInfo=0x%x)", threadId, pInfo); + sceLibKernel.Todo("sceKernelGetThreadInfo(threadId=0x%x, pInfo=0x%x)", threadId, pInfo); return SCE_OK; } @@ -250,7 +248,7 @@ s32 sceKernelGetSystemInfo(vm::psv::ptr pInfo) s32 sceKernelGetThreadmgrUIDClass(s32 uid) { - sceLibKernel.Todo("sceKernelGetThreadmgrUIDClass(uid=%d)", uid); + sceLibKernel.Todo("sceKernelGetThreadmgrUIDClass(uid=0x%x)", uid); return SCE_OK; } @@ -283,24 +281,56 @@ s32 sceKernelDelayThreadCB(u32 usec) return SCE_OK; } -s32 sceKernelWaitThreadEnd(s32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) +s32 sceKernelWaitThreadEnd(u32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) { - sceLibKernel.Todo("sceKernelWaitThreadEnd(threadId=%d, pExitStatus=0x%x, pTimeout=0x%x)", threadId, pExitStatus, pTimeout); + sceLibKernel.Error("sceKernelWaitThreadEnd(threadId=0x%x, pExitStatus=0x%x, pTimeout=0x%x)", threadId, pExitStatus, pTimeout); + + std::shared_ptr t = Emu.GetCPU().GetThread(threadId); + + if (!t || t->GetType() != CPU_THREAD_ARMv7) + { + RETURN_ERROR(SCE_KERNEL_ERROR_INVALID_UID); + } + + ARMv7Thread& thread = static_cast(*t); + + if (pTimeout) + { + } + + while (thread.IsAlive()) + { + if (Emu.IsStopped()) + { + sceLibKernel.Warning("sceKernelWaitThreadEnd(0x%x) aborted", threadId); + return SCE_OK; + } + std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack + } + + if (pExitStatus) + { + *pExitStatus = thread.context.GPR[0]; + } return SCE_OK; } -s32 sceKernelWaitThreadEndCB(s32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) +s32 sceKernelWaitThreadEndCB(u32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) { - sceLibKernel.Todo("sceKernelWaitThreadEndCB(threadId=%d, pExitStatus=0x%x, pTimeout=0x%x)", threadId, pExitStatus, pTimeout); + sceLibKernel.Todo("sceKernelWaitThreadEndCB(threadId=0x%x, pExitStatus=0x%x, pTimeout=0x%x)", threadId, pExitStatus, pTimeout); return SCE_OK; } #define REG_FUNC(nid, name) reg_psv_func(nid, &sceLibKernel, #name, &name) -psv_log_base sceLibKernel = []() -> psv_log_base +psv_log_base sceLibKernel("sceLibKernel", []() { + sceLibKernel.on_load = nullptr; + sceLibKernel.on_unload = nullptr; + sceLibKernel.on_stop = nullptr; + //REG_FUNC(0x23EAA62, sceKernelPuts); //REG_FUNC(0xB0335388, sceClibToupper); //REG_FUNC(0x4C5471BC, sceClibTolower); @@ -665,6 +695,4 @@ psv_log_base sceLibKernel = []() -> psv_log_base /* SceDebugLed */ //REG_FUNC(0x78E702D3, sceKernelSetGPO); - - return psv_log_base("sceLibKernel"); -}(); +}); diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp index 9abcf593e4..a81d82ac51 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibc.cpp @@ -1,41 +1,142 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Utilities/Log.h" #include "Emu/System.h" #include "Emu/Memory/Memory.h" #include "Emu/ARMv7/PSVFuncList.h" +#include "Emu/ARMv7/ARMv7Callback.h" extern psv_log_base sceLibc; +vm::psv::ptr g_dso; + +typedef void(*atexit_func_t)(vm::psv::ptr); + +std::vector> g_atexit; + namespace sce_libc_func { - void __cxa_atexit() + void __cxa_atexit(vm::psv::ptr func, vm::psv::ptr arg, vm::psv::ptr dso) { - sceLibc.Todo(__FUNCTION__); - Emu.Pause(); + sceLibc.Error("__cxa_atexit(func=0x%x, arg=0x%x, dso=0x%x)", func, arg, dso); + + g_atexit.insert(g_atexit.begin(), [func, arg, dso](ARMv7Context& context) + { + func(context, arg); + }); } - void exit() + void __aeabi_atexit(vm::psv::ptr arg, vm::psv::ptr func, vm::psv::ptr dso) + { + sceLibc.Error("__aeabi_atexit(arg=0x%x, func=0x%x, dso=0x%x)", arg, func, dso); + + g_atexit.insert(g_atexit.begin(), [func, arg, dso](ARMv7Context& context) + { + func(context, arg); + }); + } + + void exit(ARMv7Context& context) { sceLibc.Error("exit()"); - Emu.Pause(); + + for (auto func : g_atexit) + { + func(context); + } + + g_atexit.clear(); sceLibc.Success("Process finished"); + CallAfter([]() { Emu.Stop(); }); } - void printf(vm::psv::ptr fmt) // va_args... + std::string armv7_fmt(ARMv7Context& context, vm::psv::ptr fmt, u32 g_count, u32 f_count, u32 v_count) + { + std::string result; + + for (char c = *fmt++; c; c = *fmt++) + { + switch (c) + { + case '%': + { + const auto start = fmt - 1; + const bool number_sign = *fmt == '#' ? fmt++, true : false; + + switch (*fmt++) + { + case '%': + { + result += '%'; + continue; + } + case 'd': + case 'i': + { + // signed decimal + const s64 value = context.get_next_gpr_arg(g_count, f_count, v_count); + + result += fmt::to_sdec(value); + continue; + } + case 'x': + { + // hexadecimal + const u64 value = context.get_next_gpr_arg(g_count, f_count, v_count); + + if (number_sign && value) + { + result += "0x"; + } + + result += fmt::to_hex(value); + continue; + } + default: + { + throw fmt::Format("armv7_fmt(): unknown formatting: '%s'", start.get_ptr()); + } + } + } + } + + result += c; + } + + return result; + } + + void printf(ARMv7Context& context, vm::psv::ptr fmt) // va_args... { sceLibc.Error("printf(fmt=0x%x)", fmt); - LOG_NOTICE(TTY, "%s", fmt.get_ptr()); + sceLibc.Notice("*** *fmt = '%s'", fmt.get_ptr()); + + LOG_NOTICE(TTY, armv7_fmt(context, fmt, 1, 0, 0)); } - void __cxa_set_dso_handle_main() + void sprintf(ARMv7Context& context, vm::psv::ptr str, vm::psv::ptr fmt) // va_args... { - sceLibc.Error("__cxa_set_dso_handle_main()"); + sceLibc.Error("sprintf(str=0x%x, fmt=0x%x)", str, fmt); + + sceLibc.Notice("*** *fmt = '%s'", fmt.get_ptr()); + + const std::string& result = armv7_fmt(context, fmt, 2, 0, 0); + + sceLibc.Notice("*** res -> '%s'", result); + + ::memcpy(str.get_ptr(), result.c_str(), result.size() + 1); + } + + void __cxa_set_dso_handle_main(vm::psv::ptr dso) + { + sceLibc.Error("__cxa_set_dso_handle_main(dso=0x%x)", dso); + + g_dso = dso; } void memcpy(vm::psv::ptr dst, vm::psv::ptr src, u32 size) @@ -45,6 +146,13 @@ namespace sce_libc_func ::memcpy(dst.get_ptr(), src.get_ptr(), size); } + void memset(vm::psv::ptr dst, s32 value, u32 size) + { + sceLibc.Error("memset(dst=0x%x, value=%d, size=0x%x)", dst, value, size); + + ::memset(dst.get_ptr(), value, size); + } + void _Assert(vm::psv::ptr text, vm::psv::ptr func) { sceLibc.Error("_Assert(text=0x%x, func=0x%x)", text, func); @@ -56,8 +164,15 @@ namespace sce_libc_func #define REG_FUNC(nid, name) reg_psv_func(nid, &sceLibc, #name, &sce_libc_func::name) -psv_log_base sceLibc = []() -> psv_log_base +psv_log_base sceLibc("SceLibc", []() { + g_dso.set(0); + g_atexit.clear(); + + sceLibc.on_load = nullptr; + sceLibc.on_unload = nullptr; + sceLibc.on_stop = nullptr; + REG_FUNC(0xE4531F85, _Assert); //REG_FUNC(0xE71C5CDE, _Stoul); //REG_FUNC(0x7A5CA6A3, _Stoulx); @@ -147,7 +262,7 @@ psv_log_base sceLibc = []() -> psv_log_base //REG_FUNC(0x395490DA, setbuf); //REG_FUNC(0x2CA980A0, setvbuf); //REG_FUNC(0xA1BFF606, snprintf); - //REG_FUNC(0x7449B359, sprintf); + REG_FUNC(0x7449B359, sprintf); //REG_FUNC(0xEC585241, sscanf); //REG_FUNC(0x2BCB3F01, ungetc); //REG_FUNC(0xF7915685, vfprintf); @@ -200,7 +315,7 @@ psv_log_base sceLibc = []() -> psv_log_base //REG_FUNC(0x7747F6D7, memcmp); REG_FUNC(0x7205BFDB, memcpy); //REG_FUNC(0xAF5C218D, memmove); - //REG_FUNC(0x6DC1F0D8, memset); + REG_FUNC(0x6DC1F0D8, memset); //REG_FUNC(0x1434FA46, strcat); //REG_FUNC(0xB9336E16, strchr); //REG_FUNC(0x1B58FA3B, strcmp); @@ -317,7 +432,7 @@ psv_log_base sceLibc = []() -> psv_log_base //REG_FUNC(0x9D885076, _Towctrans); //REG_FUNC(0xE980110A, _Iswctype); REG_FUNC(0x33b83b70, __cxa_atexit); - //REG_FUNC(0xEDC939E1, __aeabi_atexit); + REG_FUNC(0xEDC939E1, __aeabi_atexit); //REG_FUNC(0xB538BF48, __cxa_finalize); //REG_FUNC(0xD0310E31, __cxa_guard_acquire); //REG_FUNC(0x4ED1056F, __cxa_guard_release); @@ -350,6 +465,4 @@ psv_log_base sceLibc = []() -> psv_log_base //REG_FUNC(0x677CDE35, _Snan); //REG_FUNC(0x7D35108B, _FSnan); //REG_FUNC(0x48AEEF2A, _LSnan); - - return psv_log_base("SceLibc"); -}(); +}); diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibm.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibm.cpp index 30fcde88cb..db7745f9f3 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibm.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibm.cpp @@ -12,8 +12,12 @@ namespace sce_libm_func #define REG_FUNC(nid, name) reg_psv_func(nid, &sceLibm, #name, &sce_libm_func::name) -psv_log_base sceLibm = []() -> psv_log_base +psv_log_base sceLibm("SceLibm", []() { + sceLibm.on_load = nullptr; + sceLibm.on_unload = nullptr; + sceLibm.on_stop = nullptr; + //REG_FUNC(0xC73FE76D, _Exp); //REG_FUNC(0xFF4EAE04, _FExp); //REG_FUNC(0xB363D7D4, _LExp); @@ -212,6 +216,4 @@ psv_log_base sceLibm = []() -> psv_log_base //REG_FUNC(0x5BD0F71C, _Dsign); //REG_FUNC(0xC4F7E42C, _FDsign); //REG_FUNC(0x1DF73D2B, _LDsign); - - return psv_log_base("SceLibm"); -}(); +}); diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibstdcxx.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibstdcxx.cpp index 7813c8b8a5..ef215f0971 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibstdcxx.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibstdcxx.cpp @@ -28,8 +28,12 @@ namespace sce_libstdcxx_func #define REG_FUNC(nid, name) reg_psv_func(nid, &sceLibstdcxx, #name, &sce_libstdcxx_func::name) -psv_log_base sceLibstdcxx = []() -> psv_log_base +psv_log_base sceLibstdcxx("SceLibstdcxx", []() { + sceLibstdcxx.on_load = nullptr; + sceLibstdcxx.on_unload = nullptr; + sceLibstdcxx.on_stop = nullptr; + //REG_FUNC(0x52B0C625, std::bad_typeid::what() const); //REG_FUNC(0x64D7D074, std::bad_typeid::_Doraise() const); //REG_FUNC(0x15FB88E2, std::logic_error::what() const); @@ -976,9 +980,7 @@ psv_log_base sceLibstdcxx = []() -> psv_log_base //REG_FUNC(0x7321E731, vtable for __cxxabiv1::__vmi_class_type_info); //REG_FUNC(0x33836375, vtable for __cxxabiv1::__fundamental_type_info); //REG_FUNC(0x94664DEB, vtable for __cxxabiv1::__pointer_to_member_type_info); - - return psv_log_base("SceLibstdcxx"); -}(); +}); /* // original names diff --git a/rpcs3/Emu/ARMv7/PSVFuncList.cpp b/rpcs3/Emu/ARMv7/PSVFuncList.cpp index 84262b3b0f..bd17628f20 100644 --- a/rpcs3/Emu/ARMv7/PSVFuncList.cpp +++ b/rpcs3/Emu/ARMv7/PSVFuncList.cpp @@ -1,29 +1,12 @@ #include "stdafx.h" -#include -#include "Utilities/Log.h" -#include "Emu/System.h" +#include "ARMv7Thread.h" #include "PSVFuncList.h" std::vector g_psv_func_list; +std::vector g_psv_modules; void add_psv_func(psv_func& data) { - // setup special functions (without NIDs) - if (!g_psv_func_list.size()) - { - psv_func unimplemented; - unimplemented.nid = 0; - unimplemented.name = "Special function (unimplemented stub)"; - unimplemented.func.reset(new psv_func_detail::func_binder([](ARMv7Thread& CPU){ CPU.m_last_syscall = vm::psv::read32(CPU.PC + 4); throw "Unimplemented function executed"; })); - g_psv_func_list.push_back(unimplemented); - - psv_func hle_return; - hle_return.nid = 1; - hle_return.name = "Special function (return from HLE)"; - hle_return.func.reset(new psv_func_detail::func_binder([](ARMv7Thread& CPU){ CPU.FastStop(); })); - g_psv_func_list.push_back(hle_return); - } - g_psv_func_list.push_back(data); } @@ -49,16 +32,16 @@ u32 get_psv_func_index(psv_func* func) return (u32)res; } -void execute_psv_func_by_index(ARMv7Thread& CPU, u32 index) +void execute_psv_func_by_index(ARMv7Context& context, u32 index) { assert(index < g_psv_func_list.size()); - auto old_last_syscall = CPU.m_last_syscall; - CPU.m_last_syscall = g_psv_func_list[index].nid; + auto old_last_syscall = context.thread.m_last_syscall; + context.thread.m_last_syscall = g_psv_func_list[index].nid; - (*g_psv_func_list[index].func)(CPU); + (*g_psv_func_list[index].func)(context); - CPU.m_last_syscall = old_last_syscall; + context.thread.m_last_syscall = old_last_syscall; } extern psv_log_base sceLibc; @@ -66,10 +49,53 @@ extern psv_log_base sceLibm; extern psv_log_base sceLibstdcxx; extern psv_log_base sceLibKernel; -void list_known_psv_modules() +void initialize_psv_modules() { - sceLibc.Log(""); - sceLibm.Log(""); - sceLibstdcxx.Log(""); - sceLibKernel.Log(""); + assert(!g_psv_func_list.size() && !g_psv_modules.size()); + + // fill module list + g_psv_modules.push_back(&sceLibc); + g_psv_modules.push_back(&sceLibm); + g_psv_modules.push_back(&sceLibstdcxx); + g_psv_modules.push_back(&sceLibKernel); + + // setup special functions (without NIDs) + psv_func unimplemented; + unimplemented.nid = 0; + unimplemented.name = "Special function (unimplemented stub)"; + unimplemented.func.reset(new psv_func_detail::func_binder([](ARMv7Context& context) + { + context.thread.m_last_syscall = vm::psv::read32(context.thread.PC + 4); + throw "Unimplemented function executed"; + })); + g_psv_func_list.push_back(unimplemented); + + psv_func hle_return; + hle_return.nid = 1; + hle_return.name = "Special function (return from HLE)"; + hle_return.func.reset(new psv_func_detail::func_binder([](ARMv7Context& context) + { + context.thread.FastStop(); + })); + g_psv_func_list.push_back(hle_return); + + // load functions + for (auto module : g_psv_modules) + { + module->Init(); + } +} + +void finalize_psv_modules() +{ + for (auto module : g_psv_modules) + { + if (module->on_stop) + { + module->on_stop(); + } + } + + g_psv_func_list.clear(); + g_psv_modules.clear(); } diff --git a/rpcs3/Emu/ARMv7/PSVFuncList.h b/rpcs3/Emu/ARMv7/PSVFuncList.h index 9fe75a647a..cf34bf846e 100644 --- a/rpcs3/Emu/ARMv7/PSVFuncList.h +++ b/rpcs3/Emu/ARMv7/PSVFuncList.h @@ -1,17 +1,29 @@ #pragma once -#include "ARMv7Thread.h" +#include "ARMv7Context.h" #include "Emu/SysCalls/LogBase.h" class psv_log_base : public LogBase { std::string m_name; + void(*m_init_func)(); public: - psv_log_base(const std::string& name) + std::function on_load; + std::function on_unload; + std::function on_stop; + +public: + psv_log_base(const std::string& name, void(*init_func)()) : m_name(name) + , m_init_func(init_func) { } + void Init() + { + m_init_func(); + } + virtual const std::string& GetName() const override { return m_name; @@ -401,7 +413,7 @@ enum psv_error_codes class psv_func_caller { public: - virtual void operator()(ARMv7Thread& CPU) = 0; + virtual void operator()(ARMv7Context& CPU) = 0; virtual ~psv_func_caller(){}; }; @@ -415,6 +427,8 @@ namespace psv_func_detail ARG_STACK, }; + static const auto FIXED_STACK_FRAME_SIZE = 0x100; // described in CB_FUNC.h + template struct bind_arg; @@ -423,9 +437,14 @@ namespace psv_func_detail { static_assert(sizeof(T) <= 4, "Invalid function argument type for ARG_GENERAL"); - static __forceinline T func(ARMv7Thread& CPU) + __forceinline static T get_arg(ARMv7Context& context) { - return cast_from_armv7_gpr(CPU.GPR[g_count - 1]); + return cast_from_armv7_gpr(context.GPR[g_count - 1]); + } + + __forceinline static void put_arg(ARMv7Context& context, const T& arg) + { + context.GPR[g_count - 1] = cast_to_armv7_gpr(arg); } }; @@ -435,7 +454,11 @@ namespace psv_func_detail static_assert(f_count <= 0, "TODO: Unsupported argument type (float)"); static_assert(sizeof(T) <= 8, "Invalid function argument type for ARG_FLOAT"); - static __forceinline T func(ARMv7Thread& CPU) + __forceinline static T get_arg(ARMv7Context& context) + { + } + + __forceinline static void put_arg(ARMv7Context& context, const T& arg) { } }; @@ -446,7 +469,11 @@ namespace psv_func_detail static_assert(v_count <= 0, "TODO: Unsupported argument type (vector)"); static_assert(std::is_same::value, "Invalid function argument type for ARG_VECTOR"); - static __forceinline T func(ARMv7Thread& CPU) + __forceinline static T get_arg(ARMv7Context& context) + { + } + + __forceinline static void put_arg(ARMv7Context& context, const T& arg) { } }; @@ -458,11 +485,19 @@ namespace psv_func_detail static_assert(v_count <= 0, "TODO: Unsupported stack argument type (vector)"); static_assert(sizeof(T) <= 4, "Invalid function argument type for ARG_STACK"); - static __forceinline T func(ARMv7Thread& CPU) + __forceinline static T get_arg(ARMv7Context& context) { // TODO: check - const u32 res = CPU.GetStackArg(g_count); - return cast_from_armv7_gpr(res); + return cast_from_armv7_gpr(context.get_stack_arg(g_count)); + } + + __forceinline static void put_arg(ARMv7Context& context, const T& arg) + { + // TODO: check + const int stack_pos = (g_count - 5) * 4 - FIXED_STACK_FRAME_SIZE; + static_assert(stack_pos < 0, "TODO: Increase fixed stack frame size (arg count limit broken)"); + + context.put_stack_arg(stack_pos, cast_to_armv7_gpr(arg)); } }; @@ -474,9 +509,14 @@ namespace psv_func_detail static_assert(type == ARG_GENERAL, "Wrong use of bind_result template"); static_assert(sizeof(T) <= 4, "Invalid function result type for ARG_GENERAL"); - static __forceinline void func(ARMv7Thread& CPU, const T& result) + __forceinline static T get_result(ARMv7Context& context) { - CPU.GPR[0] = cast_to_armv7_gpr(result); + return cast_from_armv7_gpr(context.GPR[0]); + } + + __forceinline static void put_result(ARMv7Context& context, const T& result) + { + context.GPR[0] = cast_to_armv7_gpr(result); } }; @@ -485,7 +525,7 @@ namespace psv_func_detail //{ // static_assert(sizeof(T) <= 8, "Invalid function result type for ARG_FLOAT"); - // static __forceinline void func(ARMv7Thread& CPU, const T& result) + // static __forceinline void put_result(ARMv7Context& context, const T& result) // { // } //}; @@ -495,11 +535,37 @@ namespace psv_func_detail //{ // static_assert(std::is_same::value, "Invalid function result type for ARG_VECTOR"); - // static __forceinline void func(ARMv7Thread& CPU, const T& result) + // static __forceinline void put_result(ARMv7Context& context, const T& result) // { // } //}; + template + struct result_type + { + static_assert(!std::is_pointer::value, "Invalid function result type (pointer)"); + static_assert(!std::is_reference::value, "Invalid function result type (reference)"); + static const bool is_float = std::is_floating_point::value; + static const bool is_vector = std::is_same::value; + static const bind_arg_type value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); + }; + + template + struct arg_type + { + static_assert(!std::is_pointer::value, "Invalid function argument type (pointer)"); + static_assert(!std::is_reference::value, "Invalid function argument type (reference)"); + // TODO: check calculations + static const bool is_float = std::is_floating_point::value; + static const bool is_vector = std::is_same::value; + static const bind_arg_type value = is_float + ? ((f_count >= 4) ? ARG_STACK : ARG_FLOAT) + : (is_vector ? ((v_count >= 4) ? ARG_STACK : ARG_VECTOR) : ((g_count >= 4) ? ARG_STACK : ARG_GENERAL)); + static const int g_value = g_count + (is_float || is_vector ? 0 : 1); + static const int f_value = f_count + (is_float ? 1 : 0); + static const int v_value = v_count + (is_vector ? 1 : 0); + }; + template struct call_impl { @@ -526,39 +592,45 @@ namespace psv_func_detail } template - __forceinline std::tuple<> iterate(ARMv7Thread& CPU) + __forceinline std::tuple<> get_func_args(ARMv7Context& context) { // terminator return std::tuple<>(); } template - __forceinline std::tuple iterate(ARMv7Thread& CPU) + __forceinline std::tuple get_func_args(ARMv7Context& context) { - static_assert(!std::is_pointer::value, "Invalid function argument type (pointer)"); - static_assert(!std::is_reference::value, "Invalid function argument type (reference)"); - // TODO: check calculations - const bool is_float = std::is_floating_point::value; - const bool is_vector = std::is_same::value; - const bind_arg_type t = is_float - ? ((f_count >= 4) ? ARG_STACK : ARG_FLOAT) - : (is_vector ? ((v_count >= 4) ? ARG_STACK : ARG_VECTOR) : ((g_count >= 4) ? ARG_STACK : ARG_GENERAL)); - const int g = g_count + (is_float || is_vector ? 0 : 1); - const int f = f_count + (is_float ? 1 : 0); - const int v = v_count + (is_vector ? 1 : 0); + typedef arg_type type; + const bind_arg_type t = type::value; + const int g = type::g_value; + const int f = type::f_value; + const int v = type::v_value; - return std::tuple_cat(std::tuple(bind_arg::func(CPU)), iterate(CPU)); + return std::tuple_cat(std::tuple(bind_arg::get_arg(context)), get_func_args(context)); } - template - struct result_type + template + __forceinline static bool put_func_args(ARMv7Context& context) { - static_assert(!std::is_pointer::value, "Invalid function result type (pointer)"); - static_assert(!std::is_reference::value, "Invalid function result type (reference)"); - static const bool is_float = std::is_floating_point::value; - static const bool is_vector = std::is_same::value; - static const bind_arg_type value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); - }; + // terminator + return false; + } + + template + __forceinline static bool put_func_args(ARMv7Context& context, T1 arg, T... args) + { + typedef arg_type type; + const bind_arg_type t = type::value; + const int g = type::g_value; + const int f = type::f_value; + const int v = type::v_value; + + bind_arg::put_arg(context, arg); + + // return true if stack was used + return put_func_args(context, args...) || (t == ARG_STACK); + } template class func_binder; @@ -576,16 +648,16 @@ namespace psv_func_detail { } - virtual void operator()(ARMv7Thread& CPU) + virtual void operator()(ARMv7Context& context) { - call(m_call, iterate<0, 0, 0, T...>(CPU)); + call(m_call, get_func_args<0, 0, 0, T...>(context)); } }; template - class func_binder : public psv_func_caller + class func_binder : public psv_func_caller { - typedef void(*func_t)(ARMv7Thread&, T...); + typedef void(*func_t)(ARMv7Context&, T...); const func_t m_call; public: @@ -595,9 +667,9 @@ namespace psv_func_detail { } - virtual void operator()(ARMv7Thread& CPU) + virtual void operator()(ARMv7Context& context) { - call(m_call, std::tuple_cat(std::tuple(CPU), iterate<0, 0, 0, T...>(CPU))); + call(m_call, std::tuple_cat(std::tuple(context), get_func_args<0, 0, 0, T...>(context))); } }; @@ -614,16 +686,16 @@ namespace psv_func_detail { } - virtual void operator()(ARMv7Thread& CPU) + virtual void operator()(ARMv7Context& context) { - bind_result::value>::func(CPU, call(m_call, iterate<0, 0, 0, T...>(CPU))); + bind_result::value>::put_result(context, call(m_call, get_func_args<0, 0, 0, T...>(context))); } }; template - class func_binder : public psv_func_caller + class func_binder : public psv_func_caller { - typedef RT(*func_t)(ARMv7Thread&, T...); + typedef RT(*func_t)(ARMv7Context&, T...); const func_t m_call; public: @@ -633,9 +705,38 @@ namespace psv_func_detail { } - virtual void operator()(ARMv7Thread& CPU) + virtual void operator()(ARMv7Context& context) { - bind_result::value>::func(CPU, call(m_call, std::tuple_cat(std::tuple(CPU), iterate<0, 0, 0, T...>(CPU)))); + bind_result::value>::put_result(context, call(m_call, std::tuple_cat(std::tuple(context), get_func_args<0, 0, 0, T...>(context)))); + } + }; + + template + struct func_caller + { + __forceinline static RT call(ARMv7Context& context, u32 addr, T... args) + { + func_caller::call(context, addr, args...); + + return bind_result::value>::get_result(context); + } + }; + + template + struct func_caller + { + __forceinline static void call(ARMv7Context& context, u32 addr, T... args) + { + if (put_func_args<0, 0, 0, T...>(context, args...)) + { + context.SP -= FIXED_STACK_FRAME_SIZE; + context.fast_call(addr); + context.SP += FIXED_STACK_FRAME_SIZE; + } + else + { + context.fast_call(addr); + } } }; } @@ -665,5 +766,6 @@ void reg_psv_func(u32 nid, psv_log_base* module, const char* name, RT(*func)(T.. psv_func* get_psv_func_by_nid(u32 nid); u32 get_psv_func_index(psv_func* func); -void execute_psv_func_by_index(ARMv7Thread& CPU, u32 index); -void list_known_psv_modules(); +void execute_psv_func_by_index(ARMv7Context& context, u32 index); +void initialize_psv_modules(); +void finalize_psv_modules(); diff --git a/rpcs3/Emu/CPU/CPUDecoder.h b/rpcs3/Emu/CPU/CPUDecoder.h index beb0027055..0a0aea1e0c 100644 --- a/rpcs3/Emu/CPU/CPUDecoder.h +++ b/rpcs3/Emu/CPU/CPUDecoder.h @@ -5,7 +5,7 @@ class CPUDecoder { public: - virtual u8 DecodeMemory(const u32 address)=0; + virtual u32 DecodeMemory(const u32 address) = 0; virtual ~CPUDecoder() = default; }; diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index df64539f20..a69ec8338a 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -115,7 +115,7 @@ void CPUThread::SetEntry(const u32 pc) entry = pc; } -void CPUThread::NextPc(u8 instr_size) +void CPUThread::NextPc(u32 instr_size) { if(m_is_branch) { diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 7261d0f28d..dd79700c65 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -132,7 +132,7 @@ public: int ThreadStatus(); - void NextPc(u8 instr_size); + void NextPc(u32 instr_size); void SetBranch(const u32 pc, bool record_branch = false); void SetPc(const u32 pc); void SetEntry(const u32 entry); diff --git a/rpcs3/Emu/Cell/PPCDecoder.cpp b/rpcs3/Emu/Cell/PPCDecoder.cpp index de2b55fdf9..6425cf7c7a 100644 --- a/rpcs3/Emu/Cell/PPCDecoder.cpp +++ b/rpcs3/Emu/Cell/PPCDecoder.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "PPCDecoder.h" -u8 PPCDecoder::DecodeMemory(const u32 address) +u32 PPCDecoder::DecodeMemory(const u32 address) { u32 instr = vm::read32(address); Decode(instr); diff --git a/rpcs3/Emu/Cell/PPCDecoder.h b/rpcs3/Emu/Cell/PPCDecoder.h index b13ab08efd..a653f06e81 100644 --- a/rpcs3/Emu/Cell/PPCDecoder.h +++ b/rpcs3/Emu/Cell/PPCDecoder.h @@ -5,9 +5,9 @@ class PPCDecoder : public CPUDecoder { public: - virtual void Decode(const u32 code)=0; + virtual void Decode(const u32 code) = 0; - virtual u8 DecodeMemory(const u32 address); + virtual u32 DecodeMemory(const u32 address); virtual ~PPCDecoder() = default; }; diff --git a/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp b/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp index c14d0a4131..5678d5f9d9 100644 --- a/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp +++ b/rpcs3/Emu/Cell/PPULLVMRecompiler.cpp @@ -6030,7 +6030,7 @@ ppu_recompiler_llvm::ExecutionEngine::~ExecutionEngine() { } -u8 ppu_recompiler_llvm::ExecutionEngine::DecodeMemory(const u32 address) { +u32 ppu_recompiler_llvm::ExecutionEngine::DecodeMemory(const u32 address) { ExecuteFunction(&m_ppu, 0); return 0; } diff --git a/rpcs3/Emu/Cell/PPULLVMRecompiler.h b/rpcs3/Emu/Cell/PPULLVMRecompiler.h index 715e9f08ab..40a9472e1e 100644 --- a/rpcs3/Emu/Cell/PPULLVMRecompiler.h +++ b/rpcs3/Emu/Cell/PPULLVMRecompiler.h @@ -1128,7 +1128,7 @@ namespace ppu_recompiler_llvm { ExecutionEngine & operator = (const ExecutionEngine & other) = delete; ExecutionEngine & operator = (ExecutionEngine && other) = delete; - u8 DecodeMemory(const u32 address) override; + u32 DecodeMemory(const u32 address) override; private: /// PPU processor context diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index 1b977a6e52..1b85a16d21 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -45,7 +45,7 @@ public: virtual void Decode(const u32 code); - virtual u8 DecodeMemory(const u32 address); + virtual u32 DecodeMemory(const u32 address); }; #define c (*compiler) diff --git a/rpcs3/Emu/Cell/SPURecompilerCore.cpp b/rpcs3/Emu/Cell/SPURecompilerCore.cpp index 197f42987e..a829019603 100644 --- a/rpcs3/Emu/Cell/SPURecompilerCore.cpp +++ b/rpcs3/Emu/Cell/SPURecompilerCore.cpp @@ -180,7 +180,7 @@ void SPURecompilerCore::Compile(u16 pos) first = false; } -u8 SPURecompilerCore::DecodeMemory(const u32 address) +u32 SPURecompilerCore::DecodeMemory(const u32 address) { assert(CPU.ls_offset == address - CPU.PC); const u32 m_offset = CPU.ls_offset; diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index 9068888ead..38735da8ba 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -70,7 +70,7 @@ namespace vm const u32 res = static_cast(addr); if (res != addr) { - throw fmt::Format("%s(): invalid address 0x%llx", func, addr); + throw fmt::format("%s(): invalid address 0x%llx", func, addr); } return res; diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 5915a52a05..23c7123b2d 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -1,6 +1,7 @@ #pragma once class CPUThread; +struct ARMv7Context; namespace vm { @@ -332,9 +333,11 @@ namespace vm public: typedef RT(*type)(T...); - RT operator()(CPUThread& CPU, T... args) const; // defined in CB_FUNC.h, call using specified CPU thread context + RT operator()(CPUThread& CPU, T... args) const; // defined in CB_FUNC.h, call using specified PPU thread context - RT operator()(T... args) const; // defined in CB_FUNC.h, call using current CPU thread context + RT operator()(ARMv7Context& context, T... args) const; // defined in ARMv7Callback.h, passing context is mandatory + + RT operator()(T... args) const; // defined in CB_FUNC.h, call using current PPU thread context AT addr() const { diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 9944a5860f..9e17b56ddf 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -5,6 +5,7 @@ #include "Emu/System.h" #include "Emu/GameInfo.h" +#include "Emu/ARMv7/PSVFuncList.h" #include "Emu/SysCalls/Static.h" #include "Emu/SysCalls/ModuleManager.h" #include "Emu/Cell/PPUThread.h" @@ -361,6 +362,7 @@ void Emulator::Stop() LOG_NOTICE(HLE, "All threads stopped..."); + finalize_psv_modules(); m_rsx_callback = 0; // TODO: check finalization order diff --git a/rpcs3/Loader/ELF32.cpp b/rpcs3/Loader/ELF32.cpp index cb9be62759..520fb8f991 100644 --- a/rpcs3/Loader/ELF32.cpp +++ b/rpcs3/Loader/ELF32.cpp @@ -6,6 +6,7 @@ #include "ELF32.h" #include "Emu/Cell/SPUThread.h" #include "Emu/ARMv7/ARMv7Thread.h" +#include "Emu/ARMv7/ARMv7Decoder.h" #include "Emu/ARMv7/PSVFuncList.h" #include "Emu/System.h" @@ -89,7 +90,7 @@ namespace loader case MACHINE_MIPS: break; case MACHINE_ARM: { - list_known_psv_modules(); + initialize_psv_modules(); auto armv7_thr_stop_data = vm::psv::ptr::make(Memory.PSV.RAM.AllocAlign(3 * 4)); armv7_thr_stop_data[0] = 0xf870; // HACK instruction (Thumb) @@ -98,17 +99,8 @@ namespace loader u32 entry = 0; // actual entry point (ELFs entry point is ignored) u32 fnid_addr = 0; - - // load section names - //assert(m_ehdr.data_le.e_shstrndx < m_shdrs.size()); - //const u32 sname_off = m_shdrs[m_ehdr.data_le.e_shstrndx].data_le.sh_offset; - //const u32 sname_size = m_shdrs[m_ehdr.data_le.e_shstrndx].data_le.sh_size; - //const u32 sname_base = sname_size ? Memory.PSV.RAM.AllocAlign(sname_size) : 0; - //if (sname_base) - //{ - // m_stream->Seek(handler::get_stream_offset() + sname_off); - // m_stream->Read(vm::get_ptr(sname_base), sname_size); - //} + u32 code_start = 0; + u32 code_end = 0; for (auto& shdr : m_shdrs) { @@ -125,7 +117,14 @@ namespace loader name.push_back(c); } - if (!strcmp(name.c_str(), ".sceModuleInfo.rodata")) + if (!strcmp(name.c_str(), ".text")) + { + LOG_NOTICE(LOADER, ".text analysis..."); + + code_start = shdr.data_le.sh_addr; + code_end = shdr.data_le.sh_size + code_start; + } + else if (!strcmp(name.c_str(), ".sceModuleInfo.rodata")) { LOG_NOTICE(LOADER, ".sceModuleInfo.rodata analysis..."); @@ -190,6 +189,8 @@ namespace loader vm::psv::write16(addr + 2, 0); // index 0 (unimplemented stub) vm::psv::write32(addr + 4, nid); // nid } + + code_end = std::min(addr, code_end); } } else if (!strcmp(name.c_str(), ".sceRefs.rodata")) @@ -214,6 +215,7 @@ namespace loader const u32 addr = *++code; vm::psv::write16(addr + 0, 0xf240 | (data & 0x800) >> 1 | (data & 0xf000) >> 12); // MOVW vm::psv::write16(addr + 2, 0x0c00 | (data & 0x700) << 4 | (data & 0xff)); + LOG_NOTICE(LOADER, "sceRefs: movw written at 0x%x (data=0x%x)", addr, data); break; } case 0x00000030: @@ -222,22 +224,26 @@ namespace loader const u32 addr = *++code; vm::psv::write16(addr + 0, 0xf2c0 | (data & 0x8000000) >> 17 | (data & 0xf0000000) >> 28); // MOVT vm::psv::write16(addr + 2, 0x0c00 | (data & 0x7000000) >> 12 | (data & 0xff0000) >> 16); + LOG_NOTICE(LOADER, "sceRefs: movt written at 0x%x (data=0x%x)", addr, data); break; } case 0x00000000: { // probably, no operation + LOG_NOTICE(LOADER, "sceRefs: zero code"); break; } default: { - LOG_NOTICE(LOADER, "sceRefs: unknown code found (0x%08x)", *code); + LOG_ERROR(LOADER, "sceRefs: unknown code found (0x%08x)", *code); } } } } } + armv7_decoder_initialize(code_start, code_end); + arm7_thread(entry & ~1 /* TODO: Thumb/ARM encoding selection */, "main_thread").args({ Emu.GetPath()/*, "-emu"*/ }).run(); break; } diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 706aee8000..c943495597 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -516,7 +516,7 @@ namespace loader if (module && !module->Load(nid)) { - LOG_WARNING(LOADER, "Unimplemented function '%s' in '%s' module (HLE)", SysCalls::GetHLEFuncName(nid).c_str(), module_name.c_str()); + LOG_ERROR(LOADER, "Unimplemented function '%s' in '%s' module (HLE)", SysCalls::GetHLEFuncName(nid).c_str(), module_name.c_str()); } else //if (Ini.HLELogging.GetValue()) { diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index a925170fbe..42813536b7 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -52,6 +52,7 @@ + @@ -266,6 +267,8 @@ + + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 1ef837c8fd..4965248105 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -662,6 +662,9 @@ Emu\Audio\XAudio2 + + Emu\CPU\ARMv7 + @@ -1282,5 +1285,11 @@ Emu\SysCalls\Modules + + Emu\CPU\ARMv7 + + + Emu\CPU\ARMv7 + \ No newline at end of file