Fixing 64-bit mov encoding. *shakes fist at xbyak for silently coercing*

This commit is contained in:
Ben Vanik
2014-01-27 21:32:58 -08:00
parent 8894a0f86e
commit da36baba8d
2 changed files with 27 additions and 8 deletions

View File

@@ -14,6 +14,21 @@
namespace {
// Moves a 64bit immediate into memory.
void MovMem64(X64Emitter& e, RegExp& addr, uint64_t v) {
if ((v & ~0x7FFFFFFF) == 0) {
// Fits under 31 bits, so just load using normal mov.
e.mov(e.qword[addr], v);
} else if ((v & ~0x7FFFFFFF) == ~0x7FFFFFFF) {
// Negative number that fits in 32bits.
e.mov(e.qword[addr], v);
} else {
// 64bit number that needs double movs.
e.mov(e.rax, v);
e.mov(e.qword[addr], e.rax);
}
}
// Sets EFLAGs with zf for the given value.
// ZF = 1 if false, 0 = true (so jz = jump if false)
void CheckBoolean(X64Emitter& e, Value* v) {