5
votes

I'm working with binary MIPS instructions and I found this helpful document. However, I would need a clarification: all branch instructions have an immediate value. Is this immediate value sign-extended?

Most other immediates are, and if not that would mean a backwards jump is basically impossible, so I highly suspect that yes. However, I could not find another source that talks about the binary format of MIPS instruction to clarify.

1

1 Answers

6
votes

Yes, all branch instructions use PC-relative addressing, which involves shifting the immediate field 2 bits left (to make efficient use of the otherwise 2 wasted lower-order bits; remember that all instructions are word-aligned) and then applying the sign-extension (you may address from PC - 2^17 up to PC + (2^17)-4). Here's a summary on addressing modes.