MIPS Instruction Formats
“Draw all MIPS instruction formats” (Q3(a)). MIPS is RISC: every instruction is exactly 32 bits, and there are only three formats.
Overview
Simple instructions — all 32 bits wide · very structured, no unnecessary baggage · only three formats: R, I, J.
R-type (“R” for aRithmetic)
Register-to-register operations: add, sub, and, or, nor, slt. Example add $t0, $s1, $s2.
| Field | Meaning |
|---|---|
| op | opcode — the operation. For R-type it is 000000. |
| rs | first source register |
| rt | second source register |
| rd | destination register |
| shamt | shift amount (0 unless a shift) |
| funct | function field — selects the exact operation (add, sub, …) |
Meaning: rd = rs (op) rt. Note in assembly rd is written first, but in the encoding it sits after rs and rt.
I-type (“I” for Immediate)
Data transfer, immediates and branches: lw, sw, addi, andi, ori, slti, beq, bne. Example lw $t0, 1002($s2).
| Field | Meaning |
|---|---|
| op | opcode (e.g. lw = 100011, sw = 101011, beq = 000100, bne = 000101) |
| rs | base register (lw/sw) or first compare register (beq/bne) |
| rt | destination/source register being loaded, stored or compared |
| immediate | 16-bit constant, memory offset, or branch offset (signed) |
J-type (“J” for Jump)
Unconditional jumps: j, jal. Example j Label.
The 26-bit field is a word address (word-relative). Example: j Label where address Label = 100 bytes = 25 words → the field holds 25 = 00…011001, with op = 000010.
Side-by-side
| Type | Fields (bits) | Used by |
|---|---|---|
| R | op6 · rs5 · rt5 · rd5 · shamt5 · funct6 | add, sub, and, or, slt |
| I | op6 · rs5 · rt5 · imm16 | lw, sw, addi, beq, bne |
| J | op6 · address26 | j, jal |
· · . All three add up to 32 bits — that’s the RISC “fixed-length” property. Try encodings on the Live MIPS Encoder →