1
0
Fork 0
forked from suyu/suyu

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

@ -3472,15 +3472,9 @@ static tdstate decode_thumb_instr(u32 inst, u32 addr, u32* arm_inst, u32* inst_s
// Check if in Thumb mode
tdstate ret = thumb_translate (addr, inst, arm_inst, inst_size);
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 table_length = sizeof(arm_instruction_trans) / sizeof(transop_fp_t);
u32 tinstr = GetThumbInstruction(inst, addr);
switch ((tinstr & 0xF800) >> 11) {
case 26:

View file

@ -14,13 +14,7 @@
tdstate thumb_translate(u32 addr, u32 instr, u32* ainstr, u32* inst_size) {
tdstate valid = t_uninitialized;
u32 tinstr = instr;
// The endian should be judge here
if((addr & 0x3) != 0)
tinstr = instr >> 16;
else
tinstr &= 0xFFFF;
u32 tinstr = GetThumbInstruction(instr, addr);
*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);
static inline u32 get_thumb_instr(u32 instr, u32 pc) {
u32 tinstr;
if ((pc & 0x3) != 0)
tinstr = instr >> 16;
else
tinstr = instr & 0xFFFF;
return tinstr;
static inline u32 GetThumbInstruction(u32 instr, u32 address) {
// Normally you would need to handle instruction endianness,
// however, it is fixed to little-endian on the MPCore, so
// there's no need to check for this beforehand.
if ((address & 0x3) != 0)
return instr >> 16;
return instr & 0xFFFF;
}