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) {
// 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;
if (ret == t_branch) {
int inst_index;
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 27:
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 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;
}