From 58a0d0f117caff819177053b5b9bdf1774a91929 Mon Sep 17 00:00:00 2001 From: Sintendo Date: Fri, 14 Sep 2018 22:08:11 +0200 Subject: [PATCH] x64EmitterTest: test MOV with 64-bit immediates --- Source/UnitTests/Common/x64EmitterTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/UnitTests/Common/x64EmitterTest.cpp b/Source/UnitTests/Common/x64EmitterTest.cpp index 4de8bf99ad..77f8db9aea 100644 --- a/Source/UnitTests/Common/x64EmitterTest.cpp +++ b/Source/UnitTests/Common/x64EmitterTest.cpp @@ -547,6 +547,24 @@ TWO_OP_ARITH_TEST(OR) TWO_OP_ARITH_TEST(XOR) TWO_OP_ARITH_TEST(MOV) +TEST_F(x64EmitterTest, MOV_Imm64) +{ + for (size_t i = 0; i < reg64names.size(); i++) + { + emitter->MOV(64, R(reg64names[i].reg), Imm64(0xDEADBEEFDEADBEEF)); + EXPECT_EQ(emitter->GetCodePtr(), code_buffer + 10); + ExpectDisassembly("mov " + reg64names[i].name + ", 0xdeadbeefdeadbeef"); + + emitter->MOV(64, R(reg64names[i].reg), Imm64(0xFFFFFFFFDEADBEEF)); + EXPECT_EQ(emitter->GetCodePtr(), code_buffer + 7); + ExpectDisassembly("mov " + reg64names[i].name + ", 0xffffffffdeadbeef"); + + emitter->MOV(64, R(reg64names[i].reg), Imm64(0xDEADBEEF)); + EXPECT_EQ(emitter->GetCodePtr(), code_buffer + 5 + (i > 7)); + ExpectDisassembly("mov " + reg32names[i].name + ", 0xdeadbeef"); + } +} + // TODO: Disassembler inverts operands here. // TWO_OP_ARITH_TEST(XCHG) // TWO_OP_ARITH_TEST(TEST)