diff --git a/src/gba/GBA-thumb.cpp b/src/gba/GBA-thumb.cpp index c28fc9fd..400ebde6 100644 --- a/src/gba/GBA-thumb.cpp +++ b/src/gba/GBA-thumb.cpp @@ -1417,6 +1417,12 @@ static INSN_REGPARM void thumb45_3(u32 opcode) CMP_RD_RS; } +// MOV Rd, Rs +static INSN_REGPARM void thumb46_0(u32 opcode) +{ + reg[opcode&7].I = reg[((opcode>>3)&7)].I; +} + // MOV Rd, Hs static INSN_REGPARM void thumb46_1(u32 opcode) { @@ -2185,7 +2191,7 @@ static insnfunc_t thumbInsnTable[1024] = { thumb40_0,thumb40_1,thumb40_2,thumb40_3,thumb41_0,thumb41_1,thumb41_2,thumb41_3, // 40 thumb42_0,thumb42_1,thumb42_2,thumb42_3,thumb43_0,thumb43_1,thumb43_2,thumb43_3, thumbUI,thumb44_1,thumb44_2,thumb44_3,thumbUI,thumb45_1,thumb45_2,thumb45_3, - thumbUI,thumb46_1,thumb46_2,thumb46_3,thumb47,thumb47,thumbUI,thumbUI, + thumb46_0,thumb46_1,thumb46_2,thumb46_3,thumb47,thumb47,thumbUI,thumbUI, thumb48,thumb48,thumb48,thumb48,thumb48,thumb48,thumb48,thumb48, // 48 thumb48,thumb48,thumb48,thumb48,thumb48,thumb48,thumb48,thumb48, thumb48,thumb48,thumb48,thumb48,thumb48,thumb48,thumb48,thumb48, diff --git a/src/gba/GBAinline.h b/src/gba/GBAinline.h index fa7d0d38..0f7fdf17 100644 --- a/src/gba/GBAinline.h +++ b/src/gba/GBAinline.h @@ -46,13 +46,11 @@ extern int cpuTotalTicks; static inline u32 CPUReadMemory(u32 address) { - int shift; u32 value; u32 oldAddress = address; #ifdef C_CORE if(address & 3) { - shift = (address & 3) << 3; address &= ~0x03; } #endif @@ -151,6 +149,7 @@ unreadable: if(oldAddress & 3) { #ifdef C_CORE + int shift = (oldAddress & 3) << 3; value = (value >> shift) | (value << (32 - shift)); #else #ifdef __GNUC__ @@ -158,10 +157,10 @@ unreadable: "shl $3 ,%%ecx;" "ror %%cl, %0" : "=r" (value) - : "r" (value), "c" (address)); + : "r" (value), "c" (oldAddress)); #else __asm { - mov ecx, address; + mov ecx, oldAddress; and ecx, 3; shl ecx, 3; ror [dword ptr value], cl; @@ -200,7 +199,7 @@ static inline u32 CPUReadHalfWord(u32 address) if(address < 0x4000) { #ifdef GBA_LOGGING if(systemVerbose & VERBOSE_ILLEGAL_READ) { - log("Illegal halfword read from bios: %08x at %08x\n", address, armMode ? + log("Illegal halfword read from bios: %08x at %08x\n", oldAddress, armMode ? armNextPC - 4 : armNextPC - 2); } #endif @@ -277,7 +276,7 @@ static inline u32 CPUReadHalfWord(u32 address) unreadable: #ifdef GBA_LOGGING if(systemVerbose & VERBOSE_ILLEGAL_READ) { - log("Illegal halfword read: %08x at %08x\n", address, armMode ? + log("Illegal halfword read: %08x at %08x\n", oldAddress, armMode ? armNextPC - 4 : armNextPC - 2); } #endif @@ -290,21 +289,18 @@ unreadable: value = CPUReadHalfWordQuick(reg[15].I); } } - break; + return value; } if(oldAddress & 1) { - value = (value >> 8) | (value << 24); - } - -#ifdef GBA_LOGGING - if(oldAddress & 1) { + value = (value >> 8) | (value << 24); + #ifdef GBA_LOGGING if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { log("Unaligned halfword read from: %08x at %08x (%08x)\n", oldAddress, armMode ? armNextPC - 4 : armNextPC - 2, value); } + #endif } -#endif return value; }