OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 // These instructions may be affected by an 0x66, 0xF2, or 0xF3 prefix. | 989 // These instructions may be affected by an 0x66, 0xF2, or 0xF3 prefix. |
990 // We do not use any three-byte opcodes, which start with 0x0F38 or 0x0F3A. | 990 // We do not use any three-byte opcodes, which start with 0x0F38 or 0x0F3A. |
991 int DisassemblerX64::TwoByteOpcodeInstruction(byte* data) { | 991 int DisassemblerX64::TwoByteOpcodeInstruction(byte* data) { |
992 byte opcode = *(data + 1); | 992 byte opcode = *(data + 1); |
993 byte* current = data + 2; | 993 byte* current = data + 2; |
994 // At return, "current" points to the start of the next instruction. | 994 // At return, "current" points to the start of the next instruction. |
995 const char* mnemonic = TwoByteMnemonic(opcode); | 995 const char* mnemonic = TwoByteMnemonic(opcode); |
996 if (operand_size_ == 0x66) { | 996 if (operand_size_ == 0x66) { |
997 // 0x66 0x0F prefix. | 997 // 0x66 0x0F prefix. |
998 int mod, regop, rm; | 998 int mod, regop, rm; |
999 get_modrm(*current, &mod, ®op, &rm); | 999 if (opcode == 0x3A) { |
1000 if (opcode == 0x6E) { | 1000 byte third_byte = *current; |
1001 AppendToBuffer("movd %s,", NameOfXMMRegister(regop)); | 1001 current = data + 3; |
1002 current += PrintRightOperand(current); | 1002 if (third_byte == 0x17) { |
1003 } else { | 1003 get_modrm(*current, &mod, ®op, &rm); |
1004 const char* mnemonic = "?"; | 1004 AppendToBuffer("extractps "); // reg/m32, xmm, imm8 |
1005 if (opcode == 0x57) { | 1005 current += PrintRightOperand(current); |
1006 mnemonic = "xorpd"; | 1006 AppendToBuffer(", %s, %d", NameOfCPURegister(regop), (*current) & 3); |
1007 } else if (opcode == 0x2E) { | 1007 current += 1; |
1008 mnemonic = "comisd"; | |
1009 } else if (opcode == 0x2F) { | |
1010 mnemonic = "ucomisd"; | |
1011 } else { | 1008 } else { |
1012 UnimplementedInstruction(); | 1009 UnimplementedInstruction(); |
1013 } | 1010 } |
1014 AppendToBuffer("%s %s,", mnemonic, NameOfXMMRegister(regop)); | 1011 } else { |
1015 current += PrintRightXMMOperand(current); | 1012 get_modrm(*current, &mod, ®op, &rm); |
| 1013 if (opcode == 0x6E) { |
| 1014 AppendToBuffer("mov%c %s,", |
| 1015 rex_w() ? 'q' : 'd', |
| 1016 NameOfXMMRegister(regop)); |
| 1017 current += PrintRightOperand(current); |
| 1018 } else if (opcode == 0x7E) { |
| 1019 AppendToBuffer("mov%c %s,", |
| 1020 rex_w() ? 'q' : 'd', |
| 1021 NameOfCPURegister(regop)); |
| 1022 current += PrintRightXMMOperand(current); |
| 1023 } else { |
| 1024 const char* mnemonic = "?"; |
| 1025 if (opcode == 0x57) { |
| 1026 mnemonic = "xorpd"; |
| 1027 } else if (opcode == 0x2E) { |
| 1028 mnemonic = "comisd"; |
| 1029 } else if (opcode == 0x2F) { |
| 1030 mnemonic = "ucomisd"; |
| 1031 } else { |
| 1032 UnimplementedInstruction(); |
| 1033 } |
| 1034 AppendToBuffer("%s %s,", mnemonic, NameOfXMMRegister(regop)); |
| 1035 current += PrintRightXMMOperand(current); |
| 1036 } |
1016 } | 1037 } |
1017 } else if (group_1_prefix_ == 0xF2) { | 1038 } else if (group_1_prefix_ == 0xF2) { |
1018 // Beginning of instructions with prefix 0xF2. | 1039 // Beginning of instructions with prefix 0xF2. |
1019 | 1040 |
1020 if (opcode == 0x11 || opcode == 0x10) { | 1041 if (opcode == 0x11 || opcode == 0x10) { |
1021 // MOVSD: Move scalar double-precision fp to/from/between XMM registers. | 1042 // MOVSD: Move scalar double-precision fp to/from/between XMM registers. |
1022 AppendToBuffer("movsd "); | 1043 AppendToBuffer("movsd "); |
1023 int mod, regop, rm; | 1044 int mod, regop, rm; |
1024 get_modrm(*current, &mod, ®op, &rm); | 1045 get_modrm(*current, &mod, ®op, &rm); |
1025 if (opcode == 0x11) { | 1046 if (opcode == 0x11) { |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 fprintf(f, "%02x", *bp); | 1664 fprintf(f, "%02x", *bp); |
1644 } | 1665 } |
1645 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { | 1666 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { |
1646 fprintf(f, " "); | 1667 fprintf(f, " "); |
1647 } | 1668 } |
1648 fprintf(f, " %s\n", buffer.start()); | 1669 fprintf(f, " %s\n", buffer.start()); |
1649 } | 1670 } |
1650 } | 1671 } |
1651 | 1672 |
1652 } // namespace disasm | 1673 } // namespace disasm |
OLD | NEW |