OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // A Disassembler object is used to disassemble a block of code instruction by | 5 // A Disassembler object is used to disassemble a block of code instruction by |
6 // instruction. The default implementation of the NameConverter object can be | 6 // instruction. The default implementation of the NameConverter object can be |
7 // overriden to modify register names or to do symbol lookup on addresses. | 7 // overriden to modify register names or to do symbol lookup on addresses. |
8 // | 8 // |
9 // The example below will disassemble a block of code and print it to stdout. | 9 // The example below will disassemble a block of code and print it to stdout. |
10 // | 10 // |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 imm21 >>= (32 - kImm21Bits); | 345 imm21 >>= (32 - kImm21Bits); |
346 out_buffer_pos_ += | 346 out_buffer_pos_ += |
347 SNPrintF(out_buffer_ + out_buffer_pos_, "%s", | 347 SNPrintF(out_buffer_ + out_buffer_pos_, "%s", |
348 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + | 348 converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + |
349 delta_pc + (imm21 << n_bits))); | 349 delta_pc + (imm21 << n_bits))); |
350 } | 350 } |
351 | 351 |
352 | 352 |
353 // Print 26-bit hex immediate value. | 353 // Print 26-bit hex immediate value. |
354 void Decoder::PrintXImm26(Instruction* instr) { | 354 void Decoder::PrintXImm26(Instruction* instr) { |
355 uint32_t imm = instr->Imm26Value() << kImmFieldShift; | 355 uint32_t target = static_cast<uint32_t>(instr->Imm26Value()) |
356 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", imm); | 356 << kImmFieldShift; |
| 357 target = (reinterpret_cast<uint32_t>(instr) & ~0xfffffff) | target; |
| 358 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", target); |
357 } | 359 } |
358 | 360 |
359 | 361 |
360 // Print 26-bit signed immediate value. | 362 // Print 26-bit signed immediate value. |
361 void Decoder::PrintSImm26(Instruction* instr) { | 363 void Decoder::PrintSImm26(Instruction* instr) { |
362 int32_t imm26 = instr->Imm26Value(); | 364 int32_t imm26 = instr->Imm26Value(); |
363 // set sign | 365 // set sign |
364 imm26 <<= (32 - kImm26Bits); | 366 imm26 <<= (32 - kImm26Bits); |
365 imm26 >>= (32 - kImm26Bits); | 367 imm26 >>= (32 - kImm26Bits); |
366 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm26); | 368 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm26); |
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1707 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
1706 } | 1708 } |
1707 } | 1709 } |
1708 | 1710 |
1709 | 1711 |
1710 #undef UNSUPPORTED | 1712 #undef UNSUPPORTED |
1711 | 1713 |
1712 } // namespace disasm | 1714 } // namespace disasm |
1713 | 1715 |
1714 #endif // V8_TARGET_ARCH_MIPS | 1716 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |