| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 | 288 |
| 289 int PrintRightOperand(byte* modrmp); | 289 int PrintRightOperand(byte* modrmp); |
| 290 int PrintOperands(const char* mnem, OperandOrder op_order, byte* data); | 290 int PrintOperands(const char* mnem, OperandOrder op_order, byte* data); |
| 291 int PrintImmediateOp(byte* data); | 291 int PrintImmediateOp(byte* data); |
| 292 int F7Instruction(byte* data); | 292 int F7Instruction(byte* data); |
| 293 int D1D3C1Instruction(byte* data); | 293 int D1D3C1Instruction(byte* data); |
| 294 int JumpShort(byte* data); | 294 int JumpShort(byte* data); |
| 295 int JumpConditional(byte* data, const char* comment); | 295 int JumpConditional(byte* data, const char* comment); |
| 296 int JumpConditionalShort(byte* data, const char* comment); | 296 int JumpConditionalShort(byte* data, const char* comment); |
| 297 int SetCC(byte* data); |
| 297 int FPUInstruction(byte* data); | 298 int FPUInstruction(byte* data); |
| 298 void AppendToBuffer(const char* format, ...); | 299 void AppendToBuffer(const char* format, ...); |
| 299 | 300 |
| 300 | 301 |
| 301 void UnimplementedInstruction() { | 302 void UnimplementedInstruction() { |
| 302 if (abort_on_unimplemented_) { | 303 if (abort_on_unimplemented_) { |
| 303 UNIMPLEMENTED(); | 304 UNIMPLEMENTED(); |
| 304 } else { | 305 } else { |
| 305 AppendToBuffer("'Unimplemented Instruction'"); | 306 AppendToBuffer("'Unimplemented Instruction'"); |
| 306 } | 307 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 const char* mnem = jump_conditional_mnem[cond]; | 571 const char* mnem = jump_conditional_mnem[cond]; |
| 571 AppendToBuffer("%s %s", mnem, NameOfAddress(dest)); | 572 AppendToBuffer("%s %s", mnem, NameOfAddress(dest)); |
| 572 if (comment != NULL) { | 573 if (comment != NULL) { |
| 573 AppendToBuffer(", %s", comment); | 574 AppendToBuffer(", %s", comment); |
| 574 } | 575 } |
| 575 return 2; | 576 return 2; |
| 576 } | 577 } |
| 577 | 578 |
| 578 | 579 |
| 579 // Returns number of bytes used, including *data. | 580 // Returns number of bytes used, including *data. |
| 581 int DisassemblerIA32::SetCC(byte* data) { |
| 582 assert(*data == 0x0F); |
| 583 byte cond = *(data+1) & 0x0F; |
| 584 const char* mnem = jump_conditional_mnem[cond]; |
| 585 AppendToBuffer("set%s ", mnem); |
| 586 PrintRightOperand(data+2); |
| 587 return 3; // includes 0x0F |
| 588 } |
| 589 |
| 590 |
| 591 // Returns number of bytes used, including *data. |
| 580 int DisassemblerIA32::FPUInstruction(byte* data) { | 592 int DisassemblerIA32::FPUInstruction(byte* data) { |
| 581 byte b1 = *data; | 593 byte b1 = *data; |
| 582 byte b2 = *(data + 1); | 594 byte b2 = *(data + 1); |
| 583 if (b1 == 0xD9) { | 595 if (b1 == 0xD9) { |
| 584 const char* mnem = NULL; | 596 const char* mnem = NULL; |
| 585 switch (b2) { | 597 switch (b2) { |
| 586 case 0xE8: mnem = "fld1"; break; | 598 case 0xE8: mnem = "fld1"; break; |
| 587 case 0xEE: mnem = "fldz"; break; | 599 case 0xEE: mnem = "fldz"; break; |
| 588 case 0xE1: mnem = "fabs"; break; | 600 case 0xE1: mnem = "fabs"; break; |
| 589 case 0xE0: mnem = "fchs"; break; | 601 case 0xE0: mnem = "fchs"; break; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 const char* f0mnem = F0Mnem(f0byte); | 826 const char* f0mnem = F0Mnem(f0byte); |
| 815 if (f0byte == 0xA2 || f0byte == 0x31) { | 827 if (f0byte == 0xA2 || f0byte == 0x31) { |
| 816 AppendToBuffer("%s", f0mnem); | 828 AppendToBuffer("%s", f0mnem); |
| 817 data += 2; | 829 data += 2; |
| 818 } else if ((f0byte & 0xF0) == 0x80) { | 830 } else if ((f0byte & 0xF0) == 0x80) { |
| 819 data += JumpConditional(data, branch_hint); | 831 data += JumpConditional(data, branch_hint); |
| 820 } else if (f0byte == 0xBE || f0byte == 0xBF || f0byte == 0xB6 || | 832 } else if (f0byte == 0xBE || f0byte == 0xBF || f0byte == 0xB6 || |
| 821 f0byte == 0xB7 || f0byte == 0xAF) { | 833 f0byte == 0xB7 || f0byte == 0xAF) { |
| 822 data += 2; | 834 data += 2; |
| 823 data += PrintOperands(f0mnem, REG_OPER_OP_ORDER, data); | 835 data += PrintOperands(f0mnem, REG_OPER_OP_ORDER, data); |
| 836 } else if ((f0byte & 0xF0) == 0x90) { |
| 837 data += SetCC(data); |
| 824 } else { | 838 } else { |
| 825 data += 2; | 839 data += 2; |
| 826 if (f0byte == 0xAB || f0byte == 0xA5 || f0byte == 0xAD) { | 840 if (f0byte == 0xAB || f0byte == 0xA5 || f0byte == 0xAD) { |
| 827 // shrd, shld, bts | 841 // shrd, shld, bts |
| 828 AppendToBuffer("%s ", f0mnem); | 842 AppendToBuffer("%s ", f0mnem); |
| 829 int mod, regop, rm; | 843 int mod, regop, rm; |
| 830 get_modrm(*data, &mod, ®op, &rm); | 844 get_modrm(*data, &mod, ®op, &rm); |
| 831 data += PrintRightOperand(data); | 845 data += PrintRightOperand(data); |
| 832 if (f0byte == 0xAB) { | 846 if (f0byte == 0xAB) { |
| 833 AppendToBuffer(",%s", NameOfCPURegister(regop)); | 847 AppendToBuffer(",%s", NameOfCPURegister(regop)); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 } | 1145 } |
| 1132 for (int i = 6 - (pc - prev_pc); i >= 0; i--) { | 1146 for (int i = 6 - (pc - prev_pc); i >= 0; i--) { |
| 1133 fprintf(f, " "); | 1147 fprintf(f, " "); |
| 1134 } | 1148 } |
| 1135 fprintf(f, " %s\n", buffer.start()); | 1149 fprintf(f, " %s\n", buffer.start()); |
| 1136 } | 1150 } |
| 1137 } | 1151 } |
| 1138 | 1152 |
| 1139 | 1153 |
| 1140 } // namespace disasm | 1154 } // namespace disasm |
| OLD | NEW |