OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <assert.h> | 5 #include <assert.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 byte* modrmp, | 496 byte* modrmp, |
497 RegisterNameMapping direct_register_name) { | 497 RegisterNameMapping direct_register_name) { |
498 int mod, regop, rm; | 498 int mod, regop, rm; |
499 get_modrm(*modrmp, &mod, ®op, &rm); | 499 get_modrm(*modrmp, &mod, ®op, &rm); |
500 RegisterNameMapping register_name = (mod == 3) ? direct_register_name : | 500 RegisterNameMapping register_name = (mod == 3) ? direct_register_name : |
501 &DisassemblerX64::NameOfCPURegister; | 501 &DisassemblerX64::NameOfCPURegister; |
502 switch (mod) { | 502 switch (mod) { |
503 case 0: | 503 case 0: |
504 if ((rm & 7) == 5) { | 504 if ((rm & 7) == 5) { |
505 int32_t disp = *reinterpret_cast<int32_t*>(modrmp + 1); | 505 int32_t disp = *reinterpret_cast<int32_t*>(modrmp + 1); |
506 AppendToBuffer("[0x%x]", disp); | 506 AppendToBuffer("[rip+0x%x]", disp); |
507 return 5; | 507 return 5; |
508 } else if ((rm & 7) == 4) { | 508 } else if ((rm & 7) == 4) { |
509 // Codes for SIB byte. | 509 // Codes for SIB byte. |
510 byte sib = *(modrmp + 1); | 510 byte sib = *(modrmp + 1); |
511 int scale, index, base; | 511 int scale, index, base; |
512 get_sib(sib, &scale, &index, &base); | 512 get_sib(sib, &scale, &index, &base); |
513 if (index == 4 && (base & 7) == 4 && scale == 0 /*times_1*/) { | 513 if (index == 4 && (base & 7) == 4 && scale == 0 /*times_1*/) { |
514 // index == rsp means no index. Only use sib byte with no index for | 514 // index == rsp means no index. Only use sib byte with no index for |
515 // rsp and r12 base. | 515 // rsp and r12 base. |
516 AppendToBuffer("[%s]", NameOfCPURegister(base)); | 516 AppendToBuffer("[%s]", NameOfCPURegister(base)); |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 AppendToBuffer(",%s", NameOfCPURegister(regop)); | 1493 AppendToBuffer(",%s", NameOfCPURegister(regop)); |
1494 } else { | 1494 } else { |
1495 AppendToBuffer(",%s,cl", NameOfCPURegister(regop)); | 1495 AppendToBuffer(",%s,cl", NameOfCPURegister(regop)); |
1496 } | 1496 } |
1497 } else if (opcode == 0xBD) { | 1497 } else if (opcode == 0xBD) { |
1498 AppendToBuffer("%s%c ", mnemonic, operand_size_code()); | 1498 AppendToBuffer("%s%c ", mnemonic, operand_size_code()); |
1499 int mod, regop, rm; | 1499 int mod, regop, rm; |
1500 get_modrm(*current, &mod, ®op, &rm); | 1500 get_modrm(*current, &mod, ®op, &rm); |
1501 AppendToBuffer("%s,", NameOfCPURegister(regop)); | 1501 AppendToBuffer("%s,", NameOfCPURegister(regop)); |
1502 current += PrintRightOperand(current); | 1502 current += PrintRightOperand(current); |
| 1503 } else if (opcode == 0x0B) { |
| 1504 AppendToBuffer("ud2"); |
1503 } else { | 1505 } else { |
1504 UnimplementedInstruction(); | 1506 UnimplementedInstruction(); |
1505 } | 1507 } |
1506 return static_cast<int>(current - data); | 1508 return static_cast<int>(current - data); |
1507 } | 1509 } |
1508 | 1510 |
1509 | 1511 |
1510 // Mnemonics for two-byte opcode instructions starting with 0x0F. | 1512 // Mnemonics for two-byte opcode instructions starting with 0x0F. |
1511 // The argument is the second byte of the two-byte opcode. | 1513 // The argument is the second byte of the two-byte opcode. |
1512 // Returns NULL if the instruction is not handled here. | 1514 // Returns NULL if the instruction is not handled here. |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { | 2113 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { |
2112 fprintf(f, " "); | 2114 fprintf(f, " "); |
2113 } | 2115 } |
2114 fprintf(f, " %s\n", buffer.start()); | 2116 fprintf(f, " %s\n", buffer.start()); |
2115 } | 2117 } |
2116 } | 2118 } |
2117 | 2119 |
2118 } // namespace disasm | 2120 } // namespace disasm |
2119 | 2121 |
2120 #endif // V8_TARGET_ARCH_X64 | 2122 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |