0

Suppose that the program counter (PC) is set to 0x2000 0000. What range of addresses can be reached using the MIPS branch if equal (beq instruction? (In other words, what is the set of possible values for the PC after the branch instruction executes?)

eswcs
  • 5
  • 3
  • What have you tried, and where are you stuck with this? – Erik Eidt Feb 07 '23 at 16:57
  • What I understand is that you add PC + immeadiate + 4. I'm confused about what to set the immeadiate value to, in order to get the range of values – eswcs Feb 07 '23 at 17:03
  • Dig deeper into your specifications and it will tell you how the immediate is computed. Assuming it is a monotonic operation, you can then put in min and max values to find the range. (Monotonic as in "Always increasing, as the value of the independent variable increases"). – Erik Eidt Feb 07 '23 at 17:04
  • So is the minimum of the immeadiate -2^15, since in the I-format there is 16 bits of space for the immeadiate? – eswcs Feb 07 '23 at 17:08
  • Yes. Though you're still missing the formula for converting the 16-bit I-format immediate into the "immeadiate" used in the "PC + immeadiate + 4' formula. – Erik Eidt Feb 07 '23 at 17:09
  • Is it supposed to be bit shifted 2 left? To get the 00 at the end? (in binary) – eswcs Feb 07 '23 at 17:12
  • Yes, it is, so now you have a complete formula to go from I-type instruction encoding to PC values. The formula is monotonic, so just enter min & max values of the independent variable in that larger formula. (There would be two independent variables in that formula, but here the PC is given, as a constant). – Erik Eidt Feb 07 '23 at 17:13
  • Does this answer your question? [MIPS jump and branch instructions range](https://stackoverflow.com/questions/36442586/mips-jump-and-branch-instructions-range) – Erik Eidt Feb 07 '23 at 18:52

0 Answers0