Index: test/cctest/test-assembler-x64.cc |
diff --git a/test/cctest/test-assembler-x64.cc b/test/cctest/test-assembler-x64.cc |
index 446cec6adf3f8057967a9db3a669c4009ce64aa9..ddc681c0e24a176bbf339ec84f1920fd6d47d02e 100644 |
--- a/test/cctest/test-assembler-x64.cc |
+++ b/test/cctest/test-assembler-x64.cc |
@@ -141,6 +141,37 @@ TEST(AssemblerX64ArithmeticOperations) { |
} |
+TEST(AssemblerX64CmpbOperation) { |
+ // Allocate an executable page of memory. |
+ size_t actual_size; |
+ byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
+ &actual_size, |
+ true)); |
+ CHECK(buffer); |
+ Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); |
+ |
+ // Assemble a function that compare argument byte returing 1 if equal else 0. |
+ // On Windows, it compares rcx with rdx which does not require REX prefix; |
+ // on Linux, it compares rdi with rsi which requires REX prefix. |
+ |
+ Label done; |
+ __ movq(rax, Immediate(1)); |
+ __ cmpb(arg1, arg2); |
+ __ j(equal, &done); |
+ __ movq(rax, Immediate(0)); |
+ __ bind(&done); |
+ __ ret(0); |
+ |
+ CodeDesc desc; |
+ assm.GetCode(&desc); |
+ // Call the function from C++. |
+ int result = FUNCTION_CAST<F2>(buffer)(0x1002, 0x2002); |
+ CHECK_EQ(1, result); |
+ result = FUNCTION_CAST<F2>(buffer)(0x1002, 0x2003); |
+ CHECK_EQ(0, result); |
+} |
+ |
+ |
TEST(AssemblerX64ImulOperation) { |
// Allocate an executable page of memory. |
size_t actual_size; |