mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Merge pull request #596 from kevinhartman/unaligned-cleanup
Clean up unaligned 32-bit memory reads
This commit is contained in:
commit
dfe807b2cd
2 changed files with 2 additions and 35 deletions
|
@ -4422,12 +4422,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
|
||||||
inst_cream->get_addr(cpu, inst_cream->inst, addr, 1);
|
inst_cream->get_addr(cpu, inst_cream->inst, addr, 1);
|
||||||
|
|
||||||
unsigned int value = Memory::Read32(addr);
|
unsigned int value = Memory::Read32(addr);
|
||||||
if (BIT(CP15_REG(CP15_CONTROL), 22) == 1)
|
|
||||||
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
||||||
else {
|
|
||||||
value = ROTATE_RIGHT_32(value,(8*(addr&0x3)));
|
|
||||||
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BITS(inst_cream->inst, 12, 15) == 15) {
|
if (BITS(inst_cream->inst, 12, 15) == 15) {
|
||||||
// For armv5t, should enter thumb when bits[0] is non-zero.
|
// For armv5t, should enter thumb when bits[0] is non-zero.
|
||||||
|
@ -4450,12 +4445,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
|
||||||
inst_cream->get_addr(cpu, inst_cream->inst, addr, 1);
|
inst_cream->get_addr(cpu, inst_cream->inst, addr, 1);
|
||||||
|
|
||||||
unsigned int value = Memory::Read32(addr);
|
unsigned int value = Memory::Read32(addr);
|
||||||
if (BIT(CP15_REG(CP15_CONTROL), 22) == 1)
|
|
||||||
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
||||||
else {
|
|
||||||
value = ROTATE_RIGHT_32(value,(8*(addr&0x3)));
|
|
||||||
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BITS(inst_cream->inst, 12, 15) == 15) {
|
if (BITS(inst_cream->inst, 12, 15) == 15) {
|
||||||
// For armv5t, should enter thumb when bits[0] is non-zero.
|
// For armv5t, should enter thumb when bits[0] is non-zero.
|
||||||
|
@ -4699,11 +4689,6 @@ unsigned InterpreterMainLoop(ARMul_State* state) {
|
||||||
unsigned int value = Memory::Read32(addr);
|
unsigned int value = Memory::Read32(addr);
|
||||||
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
||||||
|
|
||||||
if (BIT(CP15_REG(CP15_CONTROL), 22) == 1)
|
|
||||||
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = value;
|
|
||||||
else
|
|
||||||
cpu->Reg[BITS(inst_cream->inst, 12, 15)] = ROTATE_RIGHT_32(value,(8*(addr&0x3))) ;
|
|
||||||
|
|
||||||
if (BITS(inst_cream->inst, 12, 15) == 15) {
|
if (BITS(inst_cream->inst, 12, 15) == 15) {
|
||||||
INC_PC(sizeof(ldst_inst));
|
INC_PC(sizeof(ldst_inst));
|
||||||
goto DISPATCH;
|
goto DISPATCH;
|
||||||
|
|
|
@ -236,30 +236,12 @@ u8 Read8(const VAddr addr) {
|
||||||
u16 Read16(const VAddr addr) {
|
u16 Read16(const VAddr addr) {
|
||||||
u16_le data = 0;
|
u16_le data = 0;
|
||||||
Read<u16_le>(data, addr);
|
Read<u16_le>(data, addr);
|
||||||
|
|
||||||
// Check for 16-bit unaligned memory reads...
|
|
||||||
if (addr & 1) {
|
|
||||||
// TODO(bunnei): Implement 16-bit unaligned memory reads
|
|
||||||
LOG_ERROR(HW_Memory, "16-bit unaligned memory reads are not implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (u16)data;
|
return (u16)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Read32(const VAddr addr) {
|
u32 Read32(const VAddr addr) {
|
||||||
u32_le data = 0;
|
u32_le data = 0;
|
||||||
Read<u32_le>(data, addr);
|
Read<u32_le>(data, addr);
|
||||||
|
|
||||||
// Check for 32-bit unaligned memory reads...
|
|
||||||
if (addr & 3) {
|
|
||||||
// ARM allows for unaligned memory reads, however older ARM architectures read out memory
|
|
||||||
// from unaligned addresses in a shifted way. Our ARM CPU core (SkyEye) corrects for this,
|
|
||||||
// so therefore expects the memory to be read out in this manner.
|
|
||||||
// TODO(bunnei): Determine if this is necessary - perhaps it is OK to remove this from both
|
|
||||||
// SkyEye and here?
|
|
||||||
int shift = (addr & 3) * 8;
|
|
||||||
data = (data << shift) | (data >> (32 - shift));
|
|
||||||
}
|
|
||||||
return (u32)data;
|
return (u32)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue