Skip to content
Permalink
Browse files
Merge pull request #6597 from lioncash/fp-load-store
Interpreter_LoadStore: Generate alignment exceptions if an FP load/store instruction's effective address is not word aligned
  • Loading branch information
degasus committed Apr 5, 2018
2 parents a882183 + 912c949 commit a9cd671
Showing 1 changed file with 130 additions and 8 deletions.
@@ -74,7 +74,15 @@ void Interpreter::lbzu(UGeckoInstruction inst)

void Interpreter::lfd(UGeckoInstruction inst)
{
const u64 temp = PowerPC::Read_U64(Helper_Get_EA(inst));
const u32 address = Helper_Get_EA(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

const u64 temp = PowerPC::Read_U64(address);

if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
riPS0(inst.FD) = temp;
@@ -83,6 +91,13 @@ void Interpreter::lfd(UGeckoInstruction inst)
void Interpreter::lfdu(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_U(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

const u64 temp = PowerPC::Read_U64(address);

if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
@@ -95,6 +110,13 @@ void Interpreter::lfdu(UGeckoInstruction inst)
void Interpreter::lfdux(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_UX(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

const u64 temp = PowerPC::Read_U64(address);

if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
@@ -106,15 +128,31 @@ void Interpreter::lfdux(UGeckoInstruction inst)

void Interpreter::lfdx(UGeckoInstruction inst)
{
const u64 temp = PowerPC::Read_U64(Helper_Get_EA_X(inst));
const u32 address = Helper_Get_EA_X(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

const u64 temp = PowerPC::Read_U64(address);

if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
riPS0(inst.FD) = temp;
}

void Interpreter::lfs(UGeckoInstruction inst)
{
const u32 temp = PowerPC::Read_U32(Helper_Get_EA(inst));
const u32 address = Helper_Get_EA(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

const u32 temp = PowerPC::Read_U32(address);

if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
{
@@ -127,6 +165,13 @@ void Interpreter::lfs(UGeckoInstruction inst)
void Interpreter::lfsu(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_U(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

const u32 temp = PowerPC::Read_U32(address);

if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
@@ -141,6 +186,13 @@ void Interpreter::lfsu(UGeckoInstruction inst)
void Interpreter::lfsux(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_UX(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

const u32 temp = PowerPC::Read_U32(address);

if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
@@ -154,7 +206,15 @@ void Interpreter::lfsux(UGeckoInstruction inst)

void Interpreter::lfsx(UGeckoInstruction inst)
{
const u32 temp = PowerPC::Read_U32(Helper_Get_EA_X(inst));
const u32 address = Helper_Get_EA_X(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

const u32 temp = PowerPC::Read_U32(address);

if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
{
@@ -300,13 +360,27 @@ void Interpreter::stbu(UGeckoInstruction inst)

void Interpreter::stfd(UGeckoInstruction inst)
{
PowerPC::Write_U64(riPS0(inst.FS), Helper_Get_EA(inst));
const u32 address = Helper_Get_EA(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U64(riPS0(inst.FS), address);
}

void Interpreter::stfdu(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_U(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U64(riPS0(inst.FS), address);
if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
{
@@ -316,13 +390,27 @@ void Interpreter::stfdu(UGeckoInstruction inst)

void Interpreter::stfs(UGeckoInstruction inst)
{
PowerPC::Write_U32(ConvertToSingle(riPS0(inst.FS)), Helper_Get_EA(inst));
const u32 address = Helper_Get_EA(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U32(ConvertToSingle(riPS0(inst.FS)), address);
}

void Interpreter::stfsu(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_U(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U32(ConvertToSingle(riPS0(inst.FS)), address);
if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
{
@@ -667,6 +755,12 @@ void Interpreter::stfdux(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_UX(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U64(riPS0(inst.FS), address);
if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
{
@@ -676,21 +770,41 @@ void Interpreter::stfdux(UGeckoInstruction inst)

void Interpreter::stfdx(UGeckoInstruction inst)
{
PowerPC::Write_U64(riPS0(inst.FS), Helper_Get_EA_X(inst));
const u32 address = Helper_Get_EA_X(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U64(riPS0(inst.FS), address);
}

// Stores Floating points into Integers indeXed
void Interpreter::stfiwx(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_X(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U32((u32)riPS0(inst.FS), address);
}

void Interpreter::stfsux(UGeckoInstruction inst)
{
const u32 address = Helper_Get_EA_UX(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U32(ConvertToSingle(riPS0(inst.FS)), address);
if (!(PowerPC::ppcState.Exceptions & EXCEPTION_DSI))
{
@@ -700,7 +814,15 @@ void Interpreter::stfsux(UGeckoInstruction inst)

void Interpreter::stfsx(UGeckoInstruction inst)
{
PowerPC::Write_U32(ConvertToSingle(riPS0(inst.FS)), Helper_Get_EA_X(inst));
const u32 address = Helper_Get_EA_X(inst);

if ((address & 0b11) != 0)
{
GenerateAlignmentException(address);
return;
}

PowerPC::Write_U32(ConvertToSingle(riPS0(inst.FS)), address);
}

void Interpreter::sthbrx(UGeckoInstruction inst)

0 comments on commit a9cd671

Please sign in to comment.