0

So I have this question that say, beq instruction is executing from 0x80000000 address, what is the lowest destination address you can reach.

the answer is 0x7ffe0004, but I couldn't figure out how to get to this result. any help please?

  • A rather unrealistic hypothetical.. 0x80000000 is in the kernel address space, and 0x7FFE0004 is in the user stack space. (No branch in the kernel would try to do that.) They should have chosen a normal user code-space address somewhere in the middle for the location of the `beq`, like 0x00500000. – Erik Eidt Jan 21 '22 at 00:58
  • Does this answer your question? [MIPS jump and branch instructions range](https://stackoverflow.com/questions/36442586/mips-jump-and-branch-instructions-range) – Michael Jan 21 '22 at 06:56
  • i got answer down below, this link didnt realy helped, thanks –  Jan 21 '22 at 12:26

1 Answers1

0

The offset is a 16-bit signed field, ranging from -32768 to +32767. That offset is in words, so it is multipied by 4. The PC will already have been advanced, so the new address is PC + 4 + 4*offset. 4 x 32768 is 0x20000. 0x80000000 + 4 - 0x20000 is 0x7ffe0004.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30