MIPS: Fix disassembler for J and JAL instructions.
authorIlija.Pavlovic <Ilija.Pavlovic@imgtec.com>
Thu, 30 Jul 2015 09:16:35 +0000 (02:16 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 30 Jul 2015 09:16:47 +0000 (09:16 +0000)
Adapted disassembler for J and JAL instructions.

TEST=cctest/test-disasm-mips/Type0,
     cctest/test-disasm-mips64/Type3
BUG=

Review URL: https://codereview.chromium.org/1258743004

Cr-Commit-Position: refs/heads/master@{#29921}

src/mips/disasm-mips.cc
src/mips64/disasm-mips64.cc

index 1d50575..4720613 100644 (file)
@@ -352,8 +352,10 @@ void Decoder::PrintPCImm21(Instruction* instr, int delta_pc, int n_bits) {
 
 // Print 26-bit hex immediate value.
 void Decoder::PrintXImm26(Instruction* instr) {
-  uint32_t imm = instr->Imm26Value() << kImmFieldShift;
-  out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", imm);
+  uint32_t target = static_cast<uint32_t>(instr->Imm26Value())
+                    << kImmFieldShift;
+  target = (reinterpret_cast<uint32_t>(instr) & ~0xfffffff) | target;
+  out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", target);
 }
 
 
index 0723190..a723bdc 100644 (file)
@@ -344,8 +344,10 @@ void Decoder::PrintPCImm21(Instruction* instr, int delta_pc, int n_bits) {
 
 // Print 26-bit hex immediate value.
 void Decoder::PrintXImm26(Instruction* instr) {
-  uint32_t imm = static_cast<uint32_t>(instr->Imm26Value()) << kImmFieldShift;
-  out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", imm);
+  uint64_t target = static_cast<uint64_t>(instr->Imm26Value())
+                    << kImmFieldShift;
+  target = (reinterpret_cast<uint64_t>(instr) & ~0xfffffff) | target;
+  out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%lx", target);
 }