From e5d417213ce67bc23ac644132828d125a59c2455 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 19 Mar 2016 15:16:16 -0400 Subject: emitter: Support arbitrary FixupBranch targets. --- src/common/x64/emitter.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/common/x64/emitter.cpp') diff --git a/src/common/x64/emitter.cpp b/src/common/x64/emitter.cpp index 1dcf2416c..6c8d10ea7 100644 --- a/src/common/x64/emitter.cpp +++ b/src/common/x64/emitter.cpp @@ -531,6 +531,22 @@ void XEmitter::SetJumpTarget(const FixupBranch& branch) } } +void XEmitter::SetJumpTarget(const FixupBranch& branch, const u8* target) +{ + if (branch.type == 0) + { + s64 distance = (s64)(target - branch.ptr); + ASSERT_MSG(distance >= -0x80 && distance < 0x80, "Jump target too far away, needs force5Bytes = true"); + branch.ptr[-1] = (u8)(s8)distance; + } + else if (branch.type == 1) + { + s64 distance = (s64)(target - branch.ptr); + ASSERT_MSG(distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register"); + ((s32*)branch.ptr)[-1] = (s32)distance; + } +} + //Single byte opcodes //There is no PUSHAD/POPAD in 64-bit mode. void XEmitter::INT3() {Write8(0xCC);} -- cgit v1.2.3