Core/DSPCore: Fix more memory accesses for linux x64

Core/Common: Add more asserts for too large displacements


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6595 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
pierre
2010-12-16 22:38:31 +00:00
parent 4295f2f008
commit a82a61c53a
2 changed files with 30 additions and 12 deletions

View File

@ -299,14 +299,17 @@ void XEmitter::JMP(const u8 *addr, bool force5Bytes)
u64 fn = (u64)addr;
if (!force5Bytes)
{
s32 distance = (s32)(fn - ((u64)code + 2)); //TODO - sanity check
s64 distance = (s64)(fn - ((u64)code + 2)); //TODO - sanity check
_assert_msg_(DYNA_REC, distance >= -0x80 && distance < 0x80, "Jump target too far away, needs force5Bytes = true");
//8 bits will do
Write8(0xEB);
Write8((u8)(s8)distance);
}
else
{
s32 distance = (s32)(fn - ((u64)code + 5)); //TODO - sanity check
s64 distance = (s64)(fn - ((u64)code + 5)); //TODO - sanity check
_assert_msg_(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register");
Write8(0xE9);
Write32((u32)(s32)distance);
}
@ -394,15 +397,16 @@ void XEmitter::J_CC(CCFlags conditionCode, const u8 * addr, bool force5Bytes)
u64 fn = (u64)addr;
if (!force5Bytes)
{
s32 distance = (s32)(fn - ((u64)code + 2));
_assert_msg_(DYNA_REC, distance < 0x80, "Jump target too far away, needs force5Bytes = true");
s64 distance = (s64)(fn - ((u64)code + 2));
_assert_msg_(DYNA_REC, distance >= -0x80 && distance < 0x80, "Jump target too far away, needs force5Bytes = true");
//8 bits will do
Write8(0x70 + conditionCode);
Write8((u8)(s8)distance);
}
else
{
s32 distance = (s32)(fn - ((u64)code + 6)); //TODO - sanity check
s64 distance = (s64)(fn - ((u64)code + 6)); //TODO - sanity check
_assert_msg_(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register");
Write8(0x0F);
Write8(0x80 + conditionCode);
Write32((u32)(s32)distance);
@ -413,13 +417,15 @@ void XEmitter::SetJumpTarget(const FixupBranch &branch)
{
if (branch.type == 0)
{
s32 distance = (s32)(code - branch.ptr);
_assert_msg_(DYNA_REC, distance < 0x80, "Jump target too far away, needs force5Bytes = true");
s64 distance = (s64)(code - branch.ptr);
_assert_msg_(DYNA_REC, distance >= -0x80 && distance < 0x80, "Jump target too far away, needs force5Bytes = true");
branch.ptr[-1] = (u8)(s8)distance;
}
else if (branch.type == 1)
{
((s32*)branch.ptr)[-1] = (s32)(code - branch.ptr);
s64 distance = (s64)(code - branch.ptr);
_assert_msg_(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register");
((s32*)branch.ptr)[-1] = (s32)distance;
}
}