lllllIIIIll
lllllIIIIll

Reputation: 25

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?

Upvotes: 0

Views: 1053

Answers (1)

Michael
Michael

Reputation: 58427

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 (e.g. 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.

Upvotes: 1

Related Questions