Instruction Set Architecture
Explore MIPS instruction encoding and decoding. See how assembly instructions are translated into 32-bit binary machine code across R-type, I-type, and J-type formats.
Used for arithmetic and logical operations between registers. All operands come from registers.
Used for operations with a constant value, memory access (load/store), and conditional branches.
Used for unconditional jumps. Provides a 26-bit address field for the jump target.
The operation code tells the CPU what type of instruction to execute. For R-type instructions, the opcode is always 000000 and the actual operation is determined by the funct field. For I-type and J-type, the opcode directly specifies the instruction.
MIPS has 32 registers ($0-$31), each addressed with 5 bits. rs is the first source register, rt is the second source (or destination in I-type), and rd is the destination register in R-type instructions.
Used only by shift instructions (SLL, SRL) to specify how many bit positions to shift. For all other R-type instructions, this field is 00000.
The funct field distinguishes between R-type operations. Since all R-type instructions share opcode 000000, this field specifies ADD (100000), SUB (100010), AND (100100), OR (100101), etc.
I-type instructions include a 16-bit constant value. This can be a memory offset (for LW/SW), an arithmetic operand (ADDI), or a branch offset (BEQ/BNE). The value is sign-extended to 32 bits before use.
J-type instructions provide 26 bits for the target address. The full 32-bit address is formed by taking the upper 4 bits of PC+4 and appending the 26-bit address shifted left by 2 (word-aligned), giving a 256 MB jump range.
- *All MIPS instructions are exactly 32 bits (fixed-length encoding), simplifying fetch and decode hardware.
- *The opcode is always in bits [31:26], allowing the control unit to quickly determine the format.
- *R-type uses 3 register addresses + funct; I-type uses 2 registers + 16-bit immediate; J-type uses 26-bit address.
- *ISA design balances instruction expressiveness against fixed-width encoding constraints.
| Assembly | Format | Opcode | rs | rt | rd / imm / addr | funct | Binary (32-bit) |
|---|---|---|---|---|---|---|---|
| Load a preset to see the encoding table | |||||||