ARMv7Context, some opcodes added

This commit is contained in:
Nekotekina 2015-01-20 18:06:15 +03:00
parent 6a2eefaf3f
commit 5dd3437da9
13 changed files with 1607 additions and 1298 deletions

View file

@ -0,0 +1,267 @@
#pragma once
class ARMv7Thread;
enum ARMv7InstructionSet
{
ARM,
Thumb,
Jazelle,
ThumbEE
};
union ARMv7Code
{
struct
{
u16 code0;
u16 code1;
};
u32 data;
};
struct ARMv7Context
{
ARMv7Thread& thread;
ARMv7Context(ARMv7Thread& thread) : thread(thread) {}
void write_pc(u32 value);
u32 read_pc();
u32 get_stack_arg(u32 pos);
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;
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
{
write_pc(value & ~1);
}
}
u32 read_gpr(u32 n)
{
assert(n < 16);
if (n < 15)
{
return GPR[n];
}
return read_pc();
}
};
template<typename T, bool is_enum = std::is_enum<T>::value>
struct cast_armv7_gpr
{
static_assert(is_enum, "Invalid type for cast_armv7_gpr");
typedef typename std::underlying_type<T>::type underlying_type;
__forceinline static u32 to_gpr(const T& value)
{
return cast_armv7_gpr<underlying_type>::to_gpr(static_cast<underlying_type>(value));
}
__forceinline static T from_gpr(const u32 reg)
{
return static_cast<T>(cast_armv7_gpr<underlying_type>::from_gpr(reg));
}
};
template<>
struct cast_armv7_gpr<u8, false>
{
__forceinline static u32 to_gpr(const u8& value)
{
return value;
}
__forceinline static u8 from_gpr(const u32 reg)
{
return static_cast<u8>(reg);
}
};
template<>
struct cast_armv7_gpr<u16, false>
{
__forceinline static u32 to_gpr(const u16& value)
{
return value;
}
__forceinline static u16 from_gpr(const u32 reg)
{
return static_cast<u16>(reg);
}
};
template<>
struct cast_armv7_gpr<u32, false>
{
__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<s8, false>
{
__forceinline static u32 to_gpr(const s8& value)
{
return value;
}
__forceinline static s8 from_gpr(const u32 reg)
{
return static_cast<s8>(reg);
}
};
template<>
struct cast_armv7_gpr<s16, false>
{
__forceinline static u32 to_gpr(const s16& value)
{
return value;
}
__forceinline static s16 from_gpr(const u32 reg)
{
return static_cast<s16>(reg);
}
};
template<>
struct cast_armv7_gpr<s32, false>
{
__forceinline static u32 to_gpr(const s32& value)
{
return value;
}
__forceinline static s32 from_gpr(const u32 reg)
{
return static_cast<s32>(reg);
}
};
template<>
struct cast_armv7_gpr<bool, false>
{
__forceinline static u32 to_gpr(const bool& value)
{
return value;
}
__forceinline static bool from_gpr(const u32 reg)
{
return reinterpret_cast<const bool&>(reg);
}
};
template<typename T>
__forceinline u32 cast_to_armv7_gpr(const T& value)
{
return cast_armv7_gpr<T>::to_gpr(value);
}
template<typename T>
__forceinline T cast_from_armv7_gpr(const u32 reg)
{
return cast_armv7_gpr<T>::from_gpr(reg);
}

View file

@ -17,32 +17,33 @@ public:
virtual u8 DecodeMemory(const u32 address)
{
m_thr.update_code(address & ~1);
ARMv7Code code;
code.code0 = vm::psv::read16(address & ~1);
code.code1 = vm::psv::read16(address + 2 & ~1);
u32 arg = address & 0x1 ? code.data : (u32)code.code0 << 16 | code.code1;
// 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();
LOG_NOTICE(GENERAL, "code0 = 0x%04x, code1 = 0x%04x, data = 0x%08x, arg = 0x%08x", code.code0, code.code1, code.data, arg);
// old decoding algorithm
/*
for (auto& opcode : ARMv7_opcode_table)
{
if ((opcode.type < A1) == ((address & 0x1) == 0) && (m_thr.m_arg & opcode.mask) == opcode.code)
if ((opcode.type < A1) == ((address & 0x1) == 0) && (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);
code.data = opcode.length == 2 ? code.code0 : arg;
(*opcode.func)(m_thr.context, code, opcode.type);
// LOG_NOTICE(GENERAL, "%s, %d \n\n", opcode.name, opcode.length);
return opcode.length;
}
}
ARMv7_instrs::UNK(&m_thr);
ARMv7_instrs::UNK(m_thr.context, code);
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;
//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;
}
};

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,5 @@
#pragma once
#include "Emu/ARMv7/ARMv7Thread.h"
#include "Emu/System.h"
#include "Utilities/Log.h"
enum ARMv7_encoding
{
T1, T2, T3, T4, A1, A2
@ -61,18 +57,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<typename T> T Shift_C(T value, SRType type, s32 amount, bool carry_in, bool& carry_out);
@ -81,283 +77,293 @@ namespace ARMv7_instrs
template<typename T> 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 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 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 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 ADR(ARMv7Thread* thr, const ARMv7_encoding type);
void ADR(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 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 ASR_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void ASR_REG(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 B(ARMv7Thread* thr, const ARMv7_encoding type);
void B(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 BFC(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void BFI(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 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 BKPT(ARMv7Thread* thr, const ARMv7_encoding type);
void BKPT(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 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 CB_Z(ARMv7Thread* thr, const ARMv7_encoding type);
void CB_Z(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void CLZ(ARMv7Thread* thr, const ARMv7_encoding type);
void CLZ(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 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 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 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 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 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 IT(ARMv7Thread* thr, const ARMv7_encoding type);
void IT(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 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 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 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 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 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 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 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 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 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 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 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 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 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 LSL_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void LSL_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 LSR_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void LSR_REG(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 MLA(ARMv7Thread* thr, const ARMv7_encoding type);
void MLS(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 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 MLA(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void MLS(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 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 MUL(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 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 MUL(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void NOP(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 ORN_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void ORN_REG(ARMv7Thread* thr, const ARMv7_encoding type);
void NOP(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 ORN_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void ORN_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void PKH(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 POP(ARMv7Thread* thr, const ARMv7_encoding type);
void PUSH(ARMv7Thread* thr, const ARMv7_encoding type);
void PKH(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 POP(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void PUSH(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 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 ROR_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void ROR_REG(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 RRX(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 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 RRX(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 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 SADD16(ARMv7Thread* thr, const ARMv7_encoding type);
void SADD8(ARMv7Thread* thr, const ARMv7_encoding type);
void SASX(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 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 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 SBFX(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 SDIV(ARMv7Thread* thr, const ARMv7_encoding type);
void SBFX(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void SEL(ARMv7Thread* thr, const ARMv7_encoding type);
void SDIV(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 SEL(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 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 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 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 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 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 STR_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void STR_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 STRB_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void STRB_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 STRD_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void STRD_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 STRH_IMM(ARMv7Thread* thr, const ARMv7_encoding type);
void STRH_REG(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 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 STRH_IMM(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void STRH_REG(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
void SVC(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 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 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 TB_(ARMv7Thread* thr, const ARMv7_encoding type);
void SVC(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 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 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 TB_(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 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);
};
@ -371,7 +377,7 @@ struct ARMv7_opcode_t
u32 length; // 2 or 4
const char* name;
ARMv7_encoding type;
void(*func)(ARMv7Thread* thr, const ARMv7_encoding type);
void(*func)(ARMv7Context& context, const ARMv7Code code, const ARMv7_encoding type);
};
// single 16-bit value
@ -548,6 +554,15 @@ static const ARMv7_opcode_t ARMv7_opcode_table[] =
ARMv7_OP4(0xfff0, 0x0fc0, 0xf930, 0x0000, T2, LDRSH_REG),
ARMv7_OP4(0x0e50, 0x0ff0, 0x0010, 0x00f0, A1, LDRSH_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, 0x0000, T1, LSL_IMM),
ARMv7_OP4(0xffef, 0x8030, 0xea4f, 0x0000, T2, LSL_IMM),
ARMv7_OP4(0x0fef, 0x0070, 0x01a0, 0x0000, A1, LSL_IMM),
@ -626,7 +641,26 @@ static const ARMv7_opcode_t ARMv7_opcode_table[] =
ARMv7_OP4(0x0fff, 0x0000, 0x092d, 0x0000, A1, PUSH),
ARMv7_OP4(0x0fff, 0x0fff, 0x052d, 0x0004, A2, PUSH),
// TODO (Q*...)
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),
@ -660,7 +694,12 @@ static const ARMv7_opcode_t ARMv7_opcode_table[] =
ARMv7_OP4(0x0fe0, 0x0010, 0x00e0, 0x0000, A1, RSC_REG),
ARMv7_OP4(0x0fe0, 0x0090, 0x00e0, 0x0010, A1, RSC_RSR),
// TODO (SADD16, SADD8, SASX)
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),
@ -677,7 +716,62 @@ static const ARMv7_opcode_t ARMv7_opcode_table[] =
ARMv7_OP4(0xfff0, 0xf0f0, 0xfaa0, 0xf080, T1, SEL),
ARMv7_OP4(0x0ff0, 0x0ff0, 0x0680, 0x0fb0, A1, SEL),
// TODO (SH*, SM*, SS*)
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),
@ -716,6 +810,15 @@ static const ARMv7_opcode_t ARMv7_opcode_table[] =
ARMv7_OP4(0xfff0, 0x0fc0, 0xf820, 0x0000, T2, STRH_REG),
ARMv7_OP4(0x0e50, 0x0ff0, 0x0000, 0x00b0, A1, STRH_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(0xff80, 0xb080, T1, SUB_SPI),
ARMv7_OP4(0xfbef, 0x8000, 0xf1ad, 0x0000, T2, SUB_SPI),
ARMv7_OP4(0xfbff, 0x8000, 0xf2ad, 0x0000, T3, SUB_SPI),
@ -735,7 +838,23 @@ static const ARMv7_opcode_t ARMv7_opcode_table[] =
ARMv7_OP2(0xff00, 0xdf00, T1, SVC),
ARMv7_OP4(0x0f00, 0x0000, 0x0f00, 0x0000, A1, SVC),
// TODO (SX*)
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_),
@ -750,9 +869,80 @@ static const ARMv7_opcode_t ARMv7_opcode_table[] =
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(0x0ff0, 0xf090, 0x0110, 0x0010, A1, TST_RSR),
// TODO (U*, V*)
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),
// TODO (V*)
};
#undef ARMv7_OP2

View file

@ -2,8 +2,8 @@
#include "Emu/ARMv7/ARMv7Thread.h"
#include "Emu/ARMv7/ARMv7Interpreter.h"
#include "Emu/System.h"
#include "Utilities/Log.h"
//#include "Emu/System.h"
//#include "Utilities/Log.h"
static const char* g_arm_reg_name[16] =
{
@ -17,12 +17,13 @@ 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;
};
#if 0
#define ARMv7_OP_2(func, type) { func, 2, type, #func "_" #type }
#define ARMv7_OP_4(func, type) { func, 4, type, #func "_" #type }
@ -30,7 +31,7 @@ struct ARMv7_Instruction
// 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 +57,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 +70,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 +90,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 +100,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 +120,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 +130,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 +161,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 +187,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 +212,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 +238,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 +259,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 +285,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 +307,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 +320,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 +346,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 +356,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 +376,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 +386,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 +406,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 +416,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 +428,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 +438,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 +458,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 +468,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 +488,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 +498,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 +515,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 +541,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 +576,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 +592,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 +612,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 +622,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 +649,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 +662,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 +697,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 +727,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 +748,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 +780,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 +799,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 +814,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 +829,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 +858,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 +887,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 +919,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 +949,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 +978,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 +1016,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 +1029,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 +1078,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 +1111,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 +1143,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 +1195,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 +1243,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 +1273,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 +1302,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 +1335,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 +1367,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 +1396,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 +1425,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 +1456,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 +1478,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 +1503,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 +1535,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 +1560,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 +1585,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 +1615,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 +1640,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 +1672,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 +1702,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 +1724,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 +1756,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 +1781,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 +1813,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 +1841,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 +1874,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 +1899,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 +1924,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 +1959,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 +2024,4 @@ static void execute_main_group(ARMv7Thread* thr)
#undef ARMv7_OP_2
#undef ARMv7_OP_4
#undef ARMv7_NULL_OP
#endif

View file

@ -10,22 +10,38 @@
#include "ARMv7DisAsm.h"
#include "ARMv7Interpreter.h"
void ARMv7Context::write_pc(u32 value)
{
thread.SetBranch(value);
}
u32 ARMv7Context::read_pc()
{
return thread.PC;
}
u32 ARMv7Context::get_stack_arg(u32 pos)
{
return vm::psv::read32(SP + sizeof(u32) * (pos - 5));
}
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 +53,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;
}
@ -110,21 +121,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);
}

View file

@ -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<typename T, bool is_enum = std::is_enum<T>::value>
struct cast_armv7_gpr
{
static_assert(is_enum, "Invalid type for cast_armv7_gpr");
typedef typename std::underlying_type<T>::type underlying_type;
__forceinline static u32 to_gpr(const T& value)
{
return cast_armv7_gpr<underlying_type>::to_gpr(static_cast<underlying_type>(value));
}
__forceinline static T from_gpr(const u32 reg)
{
return static_cast<T>(cast_armv7_gpr<underlying_type>::from_gpr(reg));
}
};
template<>
struct cast_armv7_gpr<u8, false>
{
__forceinline static u32 to_gpr(const u8& value)
{
return value;
}
__forceinline static u8 from_gpr(const u32 reg)
{
return static_cast<u8>(reg);
}
};
template<>
struct cast_armv7_gpr<u16, false>
{
__forceinline static u32 to_gpr(const u16& value)
{
return value;
}
__forceinline static u16 from_gpr(const u32 reg)
{
return static_cast<u16>(reg);
}
};
template<>
struct cast_armv7_gpr<u32, false>
{
__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<s8, false>
{
__forceinline static u32 to_gpr(const s8& value)
{
return value;
}
__forceinline static s8 from_gpr(const u32 reg)
{
return static_cast<s8>(reg);
}
};
template<>
struct cast_armv7_gpr<s16, false>
{
__forceinline static u32 to_gpr(const s16& value)
{
return value;
}
__forceinline static s16 from_gpr(const u32 reg)
{
return static_cast<s16>(reg);
}
};
template<>
struct cast_armv7_gpr<s32, false>
{
__forceinline static u32 to_gpr(const s32& value)
{
return value;
}
__forceinline static s32 from_gpr(const u32 reg)
{
return static_cast<s32>(reg);
}
};
template<>
struct cast_armv7_gpr<bool, false>
{
__forceinline static u32 to_gpr(const bool& value)
{
return value;
}
__forceinline static bool from_gpr(const u32 reg)
{
return reinterpret_cast<const bool&>(reg);
}
};
template<typename T>
__forceinline u32 cast_to_armv7_gpr(const T& value)
{
return cast_armv7_gpr<T>::to_gpr(value);
}
template<typename T>
__forceinline T cast_from_armv7_gpr(const u32 reg)
{
return cast_armv7_gpr<T>::from_gpr(reg);
}

View file

@ -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;
@ -129,23 +130,23 @@ s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::psv::ptr<const void> pAr
ARMv7Thread& thread = static_cast<ARMv7Thread&>(*t);
// push arg block onto the stack
const u32 pos = (thread.SP -= argSize);
const u32 pos = (thread.context.SP -= argSize);
memcpy(vm::get_ptr<void>(pos), pArgBlock.get_ptr(), argSize);
// set SceKernelThreadEntry function arguments
thread.write_gpr(0, argSize);
thread.write_gpr(1, pos);
thread.context.write_gpr(0, argSize);
thread.context.write_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;
}

View file

@ -2,6 +2,7 @@
#include <unordered_map>
#include "Utilities/Log.h"
#include "Emu/System.h"
#include "ARMv7Thread.h"
#include "PSVFuncList.h"
std::vector<psv_func> g_psv_func_list;
@ -14,13 +15,20 @@ void add_psv_func(psv_func& data)
psv_func unimplemented;
unimplemented.nid = 0;
unimplemented.name = "Special function (unimplemented stub)";
unimplemented.func.reset(new psv_func_detail::func_binder<void, ARMv7Thread&>([](ARMv7Thread& CPU){ CPU.m_last_syscall = vm::psv::read32(CPU.PC + 4); throw "Unimplemented function executed"; }));
unimplemented.func.reset(new psv_func_detail::func_binder<void, ARMv7Context&>([](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<void, ARMv7Thread&>([](ARMv7Thread& CPU){ CPU.FastStop(); }));
hle_return.func.reset(new psv_func_detail::func_binder<void, ARMv7Context&>([](ARMv7Context& context)
{
context.thread.FastStop();
}));
g_psv_func_list.push_back(hle_return);
}
@ -49,16 +57,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;

View file

@ -1,5 +1,5 @@
#pragma once
#include "ARMv7Thread.h"
#include "ARMv7Context.h"
#include "Emu/SysCalls/LogBase.h"
class psv_log_base : public LogBase
@ -401,7 +401,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(){};
};
@ -423,9 +423,9 @@ namespace psv_func_detail
{
static_assert(sizeof(T) <= 4, "Invalid function argument type for ARG_GENERAL");
static __forceinline T func(ARMv7Thread& CPU)
static __forceinline T func(ARMv7Context& context)
{
return cast_from_armv7_gpr<T>(CPU.GPR[g_count - 1]);
return cast_from_armv7_gpr<T>(context.GPR[g_count - 1]);
}
};
@ -435,7 +435,7 @@ 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)
static __forceinline T func(ARMv7Context& context)
{
}
};
@ -446,7 +446,7 @@ namespace psv_func_detail
static_assert(v_count <= 0, "TODO: Unsupported argument type (vector)");
static_assert(std::is_same<T, u128>::value, "Invalid function argument type for ARG_VECTOR");
static __forceinline T func(ARMv7Thread& CPU)
static __forceinline T func(ARMv7Context& context)
{
}
};
@ -458,10 +458,10 @@ 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)
static __forceinline T func(ARMv7Context& context)
{
// TODO: check
const u32 res = CPU.GetStackArg(g_count);
const u32 res = context.get_stack_arg(g_count);
return cast_from_armv7_gpr<T>(res);
}
};
@ -474,9 +474,9 @@ 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)
static __forceinline void func(ARMv7Context& context, const T& result)
{
CPU.GPR[0] = cast_to_armv7_gpr<T>(result);
context.GPR[0] = cast_to_armv7_gpr<T>(result);
}
};
@ -485,7 +485,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 func(ARMv7Context& context, const T& result)
// {
// }
//};
@ -495,7 +495,7 @@ namespace psv_func_detail
//{
// static_assert(std::is_same<T, u128>::value, "Invalid function result type for ARG_VECTOR");
// static __forceinline void func(ARMv7Thread& CPU, const T& result)
// static __forceinline void func(ARMv7Context& context, const T& result)
// {
// }
//};
@ -526,14 +526,14 @@ namespace psv_func_detail
}
template<int g_count, int f_count, int v_count>
__forceinline std::tuple<> iterate(ARMv7Thread& CPU)
__forceinline std::tuple<> iterate(ARMv7Context& context)
{
// terminator
return std::tuple<>();
}
template<int g_count, int f_count, int v_count, typename T, typename... A>
__forceinline std::tuple<T, A...> iterate(ARMv7Thread& CPU)
__forceinline std::tuple<T, A...> iterate(ARMv7Context& context)
{
static_assert(!std::is_pointer<T>::value, "Invalid function argument type (pointer)");
static_assert(!std::is_reference<T>::value, "Invalid function argument type (reference)");
@ -547,7 +547,7 @@ namespace psv_func_detail
const int f = f_count + (is_float ? 1 : 0);
const int v = v_count + (is_vector ? 1 : 0);
return std::tuple_cat(std::tuple<T>(bind_arg<T, t, g, f, v>::func(CPU)), iterate<g, f, v, A...>(CPU));
return std::tuple_cat(std::tuple<T>(bind_arg<T, t, g, f, v>::func(context)), iterate<g, f, v, A...>(context));
}
template<typename RT>
@ -576,16 +576,16 @@ namespace psv_func_detail
{
}
virtual void operator()(ARMv7Thread& CPU)
virtual void operator()(ARMv7Context& context)
{
call<void>(m_call, iterate<0, 0, 0, T...>(CPU));
call<void>(m_call, iterate<0, 0, 0, T...>(context));
}
};
template<typename... T>
class func_binder<void, ARMv7Thread&, T...> : public psv_func_caller
class func_binder<void, ARMv7Context&, T...> : public psv_func_caller
{
typedef void(*func_t)(ARMv7Thread&, T...);
typedef void(*func_t)(ARMv7Context&, T...);
const func_t m_call;
public:
@ -595,9 +595,9 @@ namespace psv_func_detail
{
}
virtual void operator()(ARMv7Thread& CPU)
virtual void operator()(ARMv7Context& context)
{
call<void>(m_call, std::tuple_cat(std::tuple<ARMv7Thread&>(CPU), iterate<0, 0, 0, T...>(CPU)));
call<void>(m_call, std::tuple_cat(std::tuple<ARMv7Context&>(context), iterate<0, 0, 0, T...>(context)));
}
};
@ -614,16 +614,16 @@ namespace psv_func_detail
{
}
virtual void operator()(ARMv7Thread& CPU)
virtual void operator()(ARMv7Context& context)
{
bind_result<RT, result_type<RT>::value>::func(CPU, call<RT>(m_call, iterate<0, 0, 0, T...>(CPU)));
bind_result<RT, result_type<RT>::value>::func(context, call<RT>(m_call, iterate<0, 0, 0, T...>(context)));
}
};
template<typename RT, typename... T>
class func_binder<RT, ARMv7Thread&, T...> : public psv_func_caller
class func_binder<RT, ARMv7Context&, T...> : public psv_func_caller
{
typedef RT(*func_t)(ARMv7Thread&, T...);
typedef RT(*func_t)(ARMv7Context&, T...);
const func_t m_call;
public:
@ -633,9 +633,9 @@ namespace psv_func_detail
{
}
virtual void operator()(ARMv7Thread& CPU)
virtual void operator()(ARMv7Context& context)
{
bind_result<RT, result_type<RT>::value>::func(CPU, call<RT>(m_call, std::tuple_cat(std::tuple<ARMv7Thread&>(CPU), iterate<0, 0, 0, T...>(CPU))));
bind_result<RT, result_type<RT>::value>::func(context, call<RT>(m_call, std::tuple_cat(std::tuple<ARMv7Context&>(context), iterate<0, 0, 0, T...>(context))));
}
};
}
@ -665,5 +665,5 @@ 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 execute_psv_func_by_index(ARMv7Context& context, u32 index);
void list_known_psv_modules();

View file

@ -70,7 +70,7 @@ namespace vm
const u32 res = static_cast<u32>(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;

View file

@ -266,6 +266,7 @@
<ClInclude Include="Crypto\unself.h" />
<ClInclude Include="Crypto\utils.h" />
<ClInclude Include="define_new_memleakdetect.h" />
<ClInclude Include="Emu\ARMv7\ARMv7Context.h" />
<ClInclude Include="Emu\ARMv7\ARMv7Decoder.h" />
<ClInclude Include="Emu\ARMv7\ARMv7DisAsm.h" />
<ClInclude Include="Emu\ARMv7\ARMv7Interpreter.h" />

View file

@ -1282,5 +1282,8 @@
<ClInclude Include="Emu\SysCalls\Modules\cellAudio.h">
<Filter>Emu\SysCalls\Modules</Filter>
</ClInclude>
<ClInclude Include="Emu\ARMv7\ARMv7Context.h">
<Filter>Emu\CPU\ARMv7</Filter>
</ClInclude>
</ItemGroup>
</Project>