ArmEmitter: make it more readable
This commit is contained in:
parent
46e7c0657f
commit
7a66a3ded1
|
@ -380,8 +380,7 @@ FixupBranch ARMXEmitter::B_CC(CCFlags Cond)
|
|||
void ARMXEmitter::B_CC(CCFlags Cond, const void *fnptr)
|
||||
{
|
||||
s32 distance = (s32)fnptr - (s32(code) + 8);
|
||||
_dbg_assert_msg_(DYNA_REC, distance > -33554432
|
||||
&& distance <= 33554432,
|
||||
_dbg_assert_msg_(DYNA_REC, distance > -0x2000000 && distance <= 0x2000000,
|
||||
"B_CC out of range (%p calls %p)", code, fnptr);
|
||||
|
||||
Write32((Cond << 28) | 0x0A000000 | ((distance >> 2) & 0x00FFFFFF));
|
||||
|
@ -399,22 +398,16 @@ FixupBranch ARMXEmitter::BL_CC(CCFlags Cond)
|
|||
void ARMXEmitter::SetJumpTarget(FixupBranch const &branch)
|
||||
{
|
||||
s32 distance = (s32(code) - 8) - (s32)branch.ptr;
|
||||
_dbg_assert_msg_(DYNA_REC, distance > -33554432
|
||||
&& distance <= 33554432,
|
||||
"SetJumpTarget out of range (%p calls %p)", code,
|
||||
branch.ptr);
|
||||
if(branch.type == 0) // B
|
||||
*(u32*)branch.ptr = (u32)(branch.condition | (10 << 24) | ((distance >> 2) &
|
||||
0x00FFFFFF));
|
||||
else // BL
|
||||
*(u32*)branch.ptr = (u32)(branch.condition | 0x0B000000 | ((distance >> 2)
|
||||
& 0x00FFFFFF));
|
||||
_dbg_assert_msg_(DYNA_REC, distance > -0x2000000 && distance <= 0x2000000,
|
||||
"SetJumpTarget out of range (%p calls %p)", code, branch.ptr);
|
||||
u32 instr = (u32)(branch.condition | ((distance >> 2) & 0x00FFFFFF));
|
||||
instr |= branch.type ? /* B */ 0x0A000000 : /* BL */ 0x0B000000;
|
||||
*(u32*)branch.ptr = instr;
|
||||
}
|
||||
void ARMXEmitter::B(const void *fnptr)
|
||||
{
|
||||
s32 distance = (s32)fnptr - (s32(code) + 8);
|
||||
_dbg_assert_msg_(DYNA_REC, distance > -33554432
|
||||
&& distance <= 33554432,
|
||||
_dbg_assert_msg_(DYNA_REC, distance > -0x2000000 && distance <= 0x2000000,
|
||||
"B out of range (%p calls %p)", code, fnptr);
|
||||
|
||||
Write32(condition | 0x0A000000 | ((distance >> 2) & 0x00FFFFFF));
|
||||
|
@ -427,7 +420,7 @@ void ARMXEmitter::B(ARMReg src)
|
|||
|
||||
bool ARMXEmitter::BLInRange(const void *fnptr) {
|
||||
s32 distance = (s32)fnptr - (s32(code) + 8);
|
||||
if (distance <= -33554432 || distance > 33554432)
|
||||
if (distance <= -0x2000000 || distance > 0x2000000)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
|
@ -436,8 +429,7 @@ bool ARMXEmitter::BLInRange(const void *fnptr) {
|
|||
void ARMXEmitter::BL(const void *fnptr)
|
||||
{
|
||||
s32 distance = (s32)fnptr - (s32(code) + 8);
|
||||
_dbg_assert_msg_(DYNA_REC, distance > -33554432
|
||||
&& distance <= 33554432,
|
||||
_dbg_assert_msg_(DYNA_REC, distance > -0x2000000 && distance <= 0x2000000,
|
||||
"BL out of range (%p calls %p)", code, fnptr);
|
||||
Write32(condition | 0x0B000000 | ((distance >> 2) & 0x00FFFFFF));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue