OLD | NEW |
1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 632 |
633 // Indirect register only source modes. | 633 // Indirect register only source modes. |
634 asm_.mov_fs(ebx, Operand(eax)); | 634 asm_.mov_fs(ebx, Operand(eax)); |
635 EXPECT_BYTES(0x64, 0x8B, 0x18); | 635 EXPECT_BYTES(0x64, 0x8B, 0x18); |
636 asm_.mov_fs(eax, Operand(ecx)); | 636 asm_.mov_fs(eax, Operand(ecx)); |
637 EXPECT_BYTES(0x64, 0x8B, 0x01); | 637 EXPECT_BYTES(0x64, 0x8B, 0x01); |
638 asm_.mov_fs(edx, Operand(ebx)); | 638 asm_.mov_fs(edx, Operand(ebx)); |
639 EXPECT_BYTES(0x64, 0x8B, 0x13); | 639 EXPECT_BYTES(0x64, 0x8B, 0x13); |
640 asm_.mov_fs(ecx, Operand(edx)); | 640 asm_.mov_fs(ecx, Operand(edx)); |
641 EXPECT_BYTES(0x64, 0x8B, 0x0A); | 641 EXPECT_BYTES(0x64, 0x8B, 0x0A); |
| 642 |
| 643 // Immediate source modes. |
| 644 asm_.mov_fs(eax, Immediate(0xCAFEBABE, kSize32Bit)); |
| 645 EXPECT_BYTES(0x64, 0xA1, 0xBE, 0xBA, 0xFE, 0xCA); |
| 646 asm_.mov_fs(ebx, Immediate(0x2C, kSize8Bit)); |
| 647 EXPECT_BYTES(0x64, 0x8B, 0x1D, 0x2C, 0x00, 0x00, 0x00); |
642 } | 648 } |
643 | 649 |
644 TEST_F(AssemblerTest, LeaRegisterIndirect) { | 650 TEST_F(AssemblerTest, LeaRegisterIndirect) { |
645 // Indirect register only source modes. | 651 // Indirect register only source modes. |
646 asm_.lea(ebx, Operand(eax)); | 652 asm_.lea(ebx, Operand(eax)); |
647 EXPECT_BYTES(0x8D, 0x18); | 653 EXPECT_BYTES(0x8D, 0x18); |
648 asm_.lea(eax, Operand(ecx)); | 654 asm_.lea(eax, Operand(ecx)); |
649 EXPECT_BYTES(0x8D, 0x01); | 655 EXPECT_BYTES(0x8D, 0x01); |
650 asm_.lea(edx, Operand(ebx)); | 656 asm_.lea(edx, Operand(ebx)); |
651 EXPECT_BYTES(0x8D, 0x13); | 657 EXPECT_BYTES(0x8D, 0x13); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 EXPECT_BYTES(0x81, 0x78, 0x0A, 0xEF, 0xBE, 0xAD, 0xDE); | 942 EXPECT_BYTES(0x81, 0x78, 0x0A, 0xEF, 0xBE, 0xAD, 0xDE); |
937 asm_.cmp(Operand(eax, Displacement(10, kSize32Bit)), | 943 asm_.cmp(Operand(eax, Displacement(10, kSize32Bit)), |
938 Immediate(0xDEADBEEF, kSize32Bit)); | 944 Immediate(0xDEADBEEF, kSize32Bit)); |
939 EXPECT_BYTES(0x81, 0xB8, 0x0A, 0x00, 0x00, 0x00, 0xEF, 0xBE, 0xAD, 0xDE); | 945 EXPECT_BYTES(0x81, 0xB8, 0x0A, 0x00, 0x00, 0x00, 0xEF, 0xBE, 0xAD, 0xDE); |
940 | 946 |
941 // Special EAX mode + immediate. | 947 // Special EAX mode + immediate. |
942 asm_.cmp(eax, Immediate(0xDEADBEEF, kSize32Bit)); | 948 asm_.cmp(eax, Immediate(0xDEADBEEF, kSize32Bit)); |
943 EXPECT_BYTES(0x3D, 0xEF, 0xBE, 0xAD, 0xDE); | 949 EXPECT_BYTES(0x3D, 0xEF, 0xBE, 0xAD, 0xDE); |
944 } | 950 } |
945 | 951 |
| 952 TEST_F(AssemblerTest, IncByte) { |
| 953 asm_.inc(Operand(eax)); |
| 954 EXPECT_BYTES(0xFE, 0x00); |
| 955 asm_.inc(Operand(ecx)); |
| 956 EXPECT_BYTES(0xFE, 0x01); |
| 957 asm_.inc(Operand(edx)); |
| 958 EXPECT_BYTES(0xFE, 0x02); |
| 959 asm_.inc(Operand(ebx)); |
| 960 EXPECT_BYTES(0xFE, 0x03); |
| 961 asm_.inc(Operand(esi)); |
| 962 EXPECT_BYTES(0xFE, 0x06); |
| 963 asm_.inc(Operand(edi)); |
| 964 EXPECT_BYTES(0xFE, 0x07); |
| 965 asm_.inc(Operand(ebp)); |
| 966 EXPECT_BYTES(0xFE, 0x45, 0x00); |
| 967 asm_.inc(Operand(esp)); |
| 968 EXPECT_BYTES(0xFE, 0x04, 0x24); |
| 969 } |
| 970 |
946 TEST_F(AssemblerTest, AddByte) { | 971 TEST_F(AssemblerTest, AddByte) { |
947 asm_.add(al, bl); | 972 asm_.add(al, bl); |
948 EXPECT_BYTES(0x02, 0xC3); | 973 EXPECT_BYTES(0x02, 0xC3); |
949 asm_.add(bh, al); | 974 asm_.add(bh, al); |
950 EXPECT_BYTES(0x02, 0xF8); | 975 EXPECT_BYTES(0x02, 0xF8); |
951 | 976 |
952 asm_.add(al, Immediate(0x0A, kSize8Bit)); | 977 asm_.add(al, Immediate(0x0A, kSize8Bit)); |
953 EXPECT_BYTES(0x04, 0x0A); | 978 EXPECT_BYTES(0x04, 0x0A); |
954 asm_.add(bh, Immediate(0x0A, kSize8Bit)); | 979 asm_.add(bh, Immediate(0x0A, kSize8Bit)); |
955 EXPECT_BYTES(0x80, 0xC7, 0x0A); | 980 EXPECT_BYTES(0x80, 0xC7, 0x0A); |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 EXPECT_EQ(&ref2, serializer_.references[1].ref); | 1673 EXPECT_EQ(&ref2, serializer_.references[1].ref); |
1649 | 1674 |
1650 EXPECT_EQ(15, serializer_.references[2].location); | 1675 EXPECT_EQ(15, serializer_.references[2].location); |
1651 EXPECT_EQ(&ref3, serializer_.references[2].ref); | 1676 EXPECT_EQ(&ref3, serializer_.references[2].ref); |
1652 | 1677 |
1653 EXPECT_EQ(19, serializer_.references[3].location); | 1678 EXPECT_EQ(19, serializer_.references[3].location); |
1654 EXPECT_EQ(&ref4, serializer_.references[3].ref); | 1679 EXPECT_EQ(&ref4, serializer_.references[3].ref); |
1655 } | 1680 } |
1656 | 1681 |
1657 } // namespace assm | 1682 } // namespace assm |
OLD | NEW |