Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MIPS range of jump instruction

Tags:

mips

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 instruction. Also in determining the number of branch/jump instructions required to get to a specific address.

Can someone provide an explanation of how this has to be calculated i.e. Considering PC at a specific address and finding the number of branch/jump instructions needed to go to a different address? For example, what if PC is at 0x10001010, what is the range of addresses of branch and jump instructions?

Or can you direct me to some online resource or book which would help me in getting a better understanding of these?

like image 543
SyncMaster Avatar asked Jan 27 '12 08:01

SyncMaster


People also ask

How far can jump instruction go in MIPS?

That means the j instruction can jump to any absolute address that can be created from the operation above. The largest value for target , therefore, is 226-1 (0x03FFFFFF), and the highest reachable address is (PC & 0xF0000000) | 0x0FFFFFFC .

What is jump instruction in MIPS?

Jump Instruction The jump instructions load a new value into the PC register, which stores the value of the instruction being executed. This causes the next instruction read from memory to be retrieved from a new location.

What is the difference between jump vs jump and link instruction in MIPS?

The difference is that the target address for JR comes from a register specified in the instruction. The jump-and-link instruction ( JAL ) behaves like the simple jump instruction ( J ), but also stores a return address in register 31 ($ra).


1 Answers

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.

like image 85
markgz Avatar answered Oct 05 '22 03:10

markgz