2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

dyncom: Remove code duplication regarding thumb instructions

This commit is contained in:
Lioncash 2015-07-27 22:22:00 -04:00
parent a507ea23c1
commit 7e4fb4db19
3 changed files with 12 additions and 23 deletions

View file

@ -3471,18 +3471,12 @@ enum {
static tdstate decode_thumb_instr(u32 inst, u32 addr, u32* arm_inst, u32* inst_size, ARM_INST_PTR* ptr_inst_base) { static tdstate decode_thumb_instr(u32 inst, u32 addr, u32* arm_inst, u32* inst_size, ARM_INST_PTR* ptr_inst_base) {
// Check if in Thumb mode // Check if in Thumb mode
tdstate ret = thumb_translate (addr, inst, arm_inst, inst_size); tdstate ret = thumb_translate (addr, inst, arm_inst, inst_size);
if(ret == t_branch){ if (ret == t_branch) {
// TODO: FIXME, endian should be judged
u32 tinstr;
if((addr & 0x3) != 0)
tinstr = inst >> 16;
else
tinstr = inst & 0xFFFF;
int inst_index; int inst_index;
int table_length = sizeof(arm_instruction_trans) / sizeof(transop_fp_t); int table_length = sizeof(arm_instruction_trans) / sizeof(transop_fp_t);
u32 tinstr = GetThumbInstruction(inst, addr);
switch((tinstr & 0xF800) >> 11){ switch ((tinstr & 0xF800) >> 11) {
case 26: case 26:
case 27: case 27:
if (((tinstr & 0x0F00) != 0x0E00) && ((tinstr & 0x0F00) != 0x0F00)){ if (((tinstr & 0x0F00) != 0x0E00) && ((tinstr & 0x0F00) != 0x0F00)){

View file

@ -14,13 +14,7 @@
tdstate thumb_translate(u32 addr, u32 instr, u32* ainstr, u32* inst_size) { tdstate thumb_translate(u32 addr, u32 instr, u32* ainstr, u32* inst_size) {
tdstate valid = t_uninitialized; tdstate valid = t_uninitialized;
u32 tinstr = instr; u32 tinstr = GetThumbInstruction(instr, addr);
// The endian should be judge here
if((addr & 0x3) != 0)
tinstr = instr >> 16;
else
tinstr &= 0xFFFF;
*ainstr = 0xDEADC0DE; // Debugging to catch non updates *ainstr = 0xDEADC0DE; // Debugging to catch non updates

View file

@ -37,11 +37,12 @@ enum tdstate {
tdstate thumb_translate(u32 addr, u32 instr, u32* ainstr, u32* inst_size); tdstate thumb_translate(u32 addr, u32 instr, u32* ainstr, u32* inst_size);
static inline u32 get_thumb_instr(u32 instr, u32 pc) { static inline u32 GetThumbInstruction(u32 instr, u32 address) {
u32 tinstr; // Normally you would need to handle instruction endianness,
if ((pc & 0x3) != 0) // however, it is fixed to little-endian on the MPCore, so
tinstr = instr >> 16; // there's no need to check for this beforehand.
else if ((address & 0x3) != 0)
tinstr = instr & 0xFFFF; return instr >> 16;
return tinstr;
return instr & 0xFFFF;
} }