简体   繁体   中英

MIPS Jump Range

I'm currently learning for a test and the following Question was in one of the old exams:

Give the MIPS code for a jump from the current instruction 1.073.742.000(Dec) to 221860(Dec).

Now first question is the j label instruction more efficent than the jr instruction?

Second I assume that 221860 is out of range to jump from 1073742000 because it's in a different 256 MB block ? So in this case I would've no choice but to use jr right?

is the j label instruction more efficent than the jr instruction?

They have different purposes.

J is used when you want to jump to the same address every time the jump is taken, and the target address is within the same 256MB region. You could also use B if the target address is within +/- 128kB ( B can also cross a 256MB region boundary as long as the target address is within the given limit). Since using JR also require one or more instructions to load the target address into a register it would be tedious to have to use it for all unconditional jumps.

JR is for when you might want to jump to a different address on different occasions (eg returning from a function, which might be called from several different places), or to jump to a different 256MB region.

So in this case I would've no choice but to use jr right?

Right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM