I'm trying to wrap my head around data paths and how it works in MIPS programming. A part of understating it, is understanding the ALU Opcodes that essentially tell the ALU which operations to carry out. For example, if we implement the basic AND, OR, ADD, SUB, NAND
and NOR
functions, we get a basic ALU Opcode distribution, i.e. AND
is 00
, OR
is 01
, ADD
is 10
, SUB
is 10
, NAND
is 10
and NOR
is 01
. But I'm not sure I understand why the ALU Opcode for sw
and lw
are 00
?
On MIPS, there is only one addressing mode: base + displacement.
In load and store instructions, the ALU performs this address computation, which is done using addition. Thus, the ALU performs the addition in: register + sign-extended immediate, which forms the address sent to the data memory.