Addressing Modes
We have seen three different instruction formats. The instruction formats can also be classified according to their addressing modes.
Register Addressing
In register addressing, the operands are all registers. R-format instructions fall into this category.
Here, the field $rs
, $rt
and $rd
all points to a register.
Immediate Addressing
In immediate addressing, the operand is a constant within the instruction itself.
There is also typically an additional restriction that the operation does not involve memory or branching.
So, this addressing mode includes addi
, andi
, ori
and slti
.
Base Addressing
This addressing mode is also called displacement addressing.
In base addressing, one of the register operand is a memory location (base address) while another immediate value correspond to the offset from the given memory location.
Two instructions in this category include lw
and sw
.
PC-Relative Addressing
Similar to base addressing but the base address usually correspond to the memory location for the instruction.
As such, the base address is given by the $PC
register.
The constant is still stored in the immediate value in the instruction.
Two instructions in this category include beq
and bne
.
Pseudo-Direct Addressing
Here, we still use the $PC
register, but only the upper 4-bits of it.
The rest of the address is obtained from the instruction.
In this case, 26-bits since the last 2 bits are guaranteed to be 00 due to word-alignment.
The instruction in this category is j
.