I am reading the book \'Computer Organization and Design\' by Patterson and Hennessy and got interested in MIPS.
I have doubts in finding the range of a jump/branch
The following is all for MIPS-32.
Branch B, BEQ, BNE, etc.
instructions have a 16 bit signed word offset field, allowing a branch to an address +/- 128kBytes from the current location. A jump J
instruction specifies an address within the current 256MByte region specified by PC's most significant 4 bits : 26<<2 bits(this is not a relative address). To branch to an arbitrary address anywhere in the 4GB address space, use JR
(jump register) which jumps to an address contained in a general purpose register.
It takes either a single branch or jump instruction, or a register load followed by a JR
to jump to an arbitrary address, depending how far away the address is.
The best book for MIPS programming is still See MIPS Run. You can also find MIPS architecture reference manuals at mips.com (registration required). The most relevant document is MIPS32® Architecture for Programmers Volume II: The MIPS32® Instruction Set.