OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/disassembler.h" | 5 #include "vm/disassembler.h" |
6 | 6 |
7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
8 #if defined(TARGET_ARCH_IA32) | 8 #if defined(TARGET_ARCH_IA32) |
9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 } | 379 } |
380 buffer_[buffer_pos_] = '\0'; | 380 buffer_[buffer_pos_] = '\0'; |
381 } | 381 } |
382 | 382 |
383 | 383 |
384 static const int kMaxCPURegisters = 8; | 384 static const int kMaxCPURegisters = 8; |
385 static const char* cpu_regs[kMaxCPURegisters] = { | 385 static const char* cpu_regs[kMaxCPURegisters] = { |
386 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" | 386 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" |
387 }; | 387 }; |
388 | 388 |
| 389 static const int kMaxByteCPURegisters = 8; |
| 390 static const char* byte_cpu_regs[kMaxByteCPURegisters] = { |
| 391 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" |
| 392 }; |
| 393 |
389 static const int kMaxXmmRegisters = 8; | 394 static const int kMaxXmmRegisters = 8; |
390 static const char* xmm_regs[kMaxXmmRegisters] = { | 395 static const char* xmm_regs[kMaxXmmRegisters] = { |
391 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" | 396 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
392 }; | 397 }; |
393 | 398 |
394 | |
395 void X86Decoder::PrintCPURegister(int reg) { | 399 void X86Decoder::PrintCPURegister(int reg) { |
396 ASSERT(0 <= reg); | 400 ASSERT(0 <= reg); |
397 ASSERT(reg < kMaxCPURegisters); | 401 ASSERT(reg < kMaxCPURegisters); |
398 Print(cpu_regs[reg]); | 402 Print(cpu_regs[reg]); |
399 } | 403 } |
400 | 404 |
401 | 405 |
402 void X86Decoder::PrintCPUByteRegister(int reg) { | 406 void X86Decoder::PrintCPUByteRegister(int reg) { |
403 UNIMPLEMENTED(); | 407 ASSERT(0 <= reg); |
| 408 ASSERT(reg < kMaxByteCPURegisters); |
| 409 Print(byte_cpu_regs[reg]); |
404 } | 410 } |
405 | 411 |
406 | 412 |
407 void X86Decoder::PrintXmmRegister(int reg) { | 413 void X86Decoder::PrintXmmRegister(int reg) { |
408 ASSERT(0 <= reg); | 414 ASSERT(0 <= reg); |
409 ASSERT(reg < kMaxXmmRegisters); | 415 ASSERT(reg < kMaxXmmRegisters); |
410 Print(xmm_regs[reg]); | 416 Print(xmm_regs[reg]); |
411 } | 417 } |
412 | 418 |
413 void X86Decoder::PrintXmmComparison(int comparison) { | 419 void X86Decoder::PrintXmmComparison(int comparison) { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 return PrintRightOperandHelper(modrmp, &X86Decoder::PrintCPURegister); | 633 return PrintRightOperandHelper(modrmp, &X86Decoder::PrintCPURegister); |
628 } | 634 } |
629 | 635 |
630 | 636 |
631 int X86Decoder::PrintRightXmmOperand(uint8_t* modrmp) { | 637 int X86Decoder::PrintRightXmmOperand(uint8_t* modrmp) { |
632 return PrintRightOperandHelper(modrmp, &X86Decoder::PrintXmmRegister); | 638 return PrintRightOperandHelper(modrmp, &X86Decoder::PrintXmmRegister); |
633 } | 639 } |
634 | 640 |
635 | 641 |
636 int X86Decoder::PrintRightByteOperand(uint8_t* modrmp) { | 642 int X86Decoder::PrintRightByteOperand(uint8_t* modrmp) { |
637 UNIMPLEMENTED(); | 643 return PrintRightOperandHelper(modrmp, &X86Decoder::PrintCPUByteRegister); |
638 return 0; | |
639 } | 644 } |
640 | 645 |
641 | 646 |
642 int X86Decoder::PrintOperands(const char* mnem, | 647 int X86Decoder::PrintOperands(const char* mnem, |
643 OperandOrder op_order, | 648 OperandOrder op_order, |
644 uint8_t* data) { | 649 uint8_t* data) { |
645 uint8_t modrm = *data; | 650 uint8_t modrm = *data; |
646 int mod, regop, rm; | 651 int mod, regop, rm; |
647 GetModRm(modrm, &mod, ®op, &rm); | 652 GetModRm(modrm, &mod, ®op, &rm); |
648 int advance = 0; | 653 int advance = 0; |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 pc); | 1802 pc); |
1798 pc += instruction_length; | 1803 pc += instruction_length; |
1799 } | 1804 } |
1800 | 1805 |
1801 return; | 1806 return; |
1802 } | 1807 } |
1803 | 1808 |
1804 } // namespace dart | 1809 } // namespace dart |
1805 | 1810 |
1806 #endif // defined TARGET_ARCH_IA32 | 1811 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |