MIPS Addressing Modes
“Draw all MIPS addressing modes” (Q3(a)) — there are five — plus the branch/jump address arithmetic they’re built on.
The five modes
| # | Mode | Example | Where the operand is |
|---|---|---|---|
| 1 | Register (R-type) | add $s1, $s2, $s3 | in a register |
| 2 | Base / displacement | lw $s1, 8($s3) | memory at (register + offset) |
| 3 | Immediate | addi $s1, $s2, 7 | a constant inside the instruction |
| 4 | PC-relative | beq $s1, $s2, Label | |
| 5 | Pseudodirect | j Label | target from the 26-bit field |
Mnemonic: Register, Base, Immediate, PC-relative, Pseudodirect → “RBI-PP”.
How each is drawn
Branch address arithmetic
beq/bne $rs, $rt, Label are I-type. The 16-bit offset counts instructions (words), relative to the next instruction.PC is the 32-bit Program Counter — it holds the address of the instruction currently executing. Normally it advances by ; if the branch is taken, .
Worked value (from the slides)
Given PC = 200, $s0 = 8, $s1 = 8, and beq $s0,$s1,Label with offset = 1: $s0 == $s1 → branch taken.
If the condition were false, instead. The offset field is the number of instructions between the branch and the target.
Encoding a branch (from the slides)
beq $s0, $s1, Label ($s0 = 16 = 10000, $s1 = 17 = 10001, offset = 1):
Jump (J-type)
j Label uses word-relative addressing: the 26-bit field is a word address. Example j Label with Label at 100 bytes = 25 words → field = 25, op = 000010: