What is the difference between register indirect and base plus offset, and how does it affect how you write assembly on the MIPS architecture? I think it means that you can only reference the register in an instruction, and that register has to point to more instructions?
Share
“Register indirect” addressing means that the address which will be used by the
instruction (known as the “effective address”) is taken from the contents of a
register, rather than being encoded directly within the instruction itself
(which is “absolute” addressing). MIPS has jump instructions for both of these
addressing modes:
means “jump to address
0x1234” (absolute addressing), whereasmeans “jump to the address contained in the
$raregister” (register indirectaddressing).
“Base plus offset” addressing means that a base address is taken from the
contents of a register, and then an offset (which is encoded in the instruction
itself) is added. MIPS uses this addressing mode for loads and stores. For
example:
…if
$a0contains0x1234, then$t0will be loaded with the word ataddress
0x1234(the effective address is the contents of the register, plusan offset of 0), and
$t1will be loaded with the word at address0x1238(the effective address is the contents of the register, plus an offset of 4).
As you can see, when the offset is 0, this is equivalent to register indirect
addressing.