1
votes

Suppose a label called L1. On MIPS, one can easily do:

beq $t1, $t2, L1

But is there a way to do the same using indirect addressing? By that, I mean using a register that holds the address where L1 is found. I know of the jr command, but I don't see how it could be used for this purpose.

1
There's no MIPS tag here because this is a computer science site, not a programming site. Migrating… - Gilles 'SO- stop being evil'

1 Answers

2
votes

beq requires an immediate value in its 3rd argument, never a register or memory address.

According to page 55 of this manual (page 63 in the PDF), the range of beq is -128 KB to +128KB, which is exactly 4 times as much as a signed 16-bit integer can represent: -32 KB to +32 KB (since instructions are 4 bytes long, a multiplier of 4 is automatically applied).

I think jr should be able to accomplish what you want. Instead of using a register to point to memory address XX, just load the value of address XX into a register and use that to jump.

lw $t0, XX
jr $t0