MIPS Instruction Decoder
Decode a 32-bit MIPS instruction from hexadecimal, binary, decimal or little-endian byte input. Inspect opcode, instruction format, source and destination registers, shift amount, funct code, immediate values, branch displacement and jump target fields.
—
| Field | Bits | Binary | Decimal | Meaning |
|---|
—
What Is a MIPS Instruction Decoder?
A MIPS Instruction Decoder converts a 32-bit machine-code word into its assembly-level fields. Depending on the opcode, the instruction can use R-type, I-type or J-type encoding.
The decoder extracts the six-bit opcode first and then interprets the remaining bits according to the selected instruction family.
MIPS 32-Bit Instruction Width
Classic MIPS instructions use fixed-width 32-bit instruction words.
32 bits
= 4 bytes
= 8 hexadecimal digitsThe fixed width makes it possible to identify major fields directly by their bit positions.
MIPS R-Type Instruction Format
31 26 25 21 20 16 15 11 10 6 5 0
+----------+--------+--------+--------+-------+---------+
| opcode | rs | rt | rd | shamt | funct |
+----------+--------+--------+--------+-------+---------+
6 bits 5 5 5 5 6For many R-type arithmetic instructions the major opcode is zero, while the lowest six-bit funct field identifies the operation.
Example: ADD $t0, $t1, $t2
Machine code:
0x012A4020
Opcode:
000000 → SPECIAL / R-Type
rs:
01001 → register 9 → $t1
rt:
01010 → register 10 → $t2
rd:
01000 → register 8 → $t0
shamt:
00000
funct:
100000 → 0x20 → ADDCommon MIPS R-Type Function Codes
| Funct | Instruction |
|---|---|
| 0x00 | SLL |
| 0x02 | SRL |
| 0x03 | SRA |
| 0x08 | JR |
| 0x09 | JALR |
| 0x0C | SYSCALL |
| 0x20 | ADD |
| 0x21 | ADDU |
| 0x22 | SUB |
| 0x23 | SUBU |
| 0x24 | AND |
| 0x25 | OR |
| 0x26 | XOR |
| 0x27 | NOR |
| 0x2A | SLT |
| 0x2B | SLTU |
MIPS I-Type Instruction Format
31 26 25 21 20 16 15 0
+----------+--------+--------+-----------------------+
| opcode | rs | rt | immediate |
+----------+--------+--------+-----------------------+
6 bits 5 5 16 bitsI-type format is used by immediate arithmetic, logical instructions, branches, loads and stores.
Signed vs Unsigned Immediate Interpretation
The meaning of the 16-bit immediate depends on the instruction.
ADDI / ADDIU:
signed 16-bit immediate
LW / SW:
signed 16-bit address offset
BEQ / BNE:
signed branch displacement
ANDI / ORI / XORI:
zero-extended 16-bit immediate
LUI:
immediate placed in upper 16 bitsMIPS Load and Store Addressing
Load and store instructions combine a base register with a signed 16-bit offset.
lw $t0, 4($sp)
Base:
$sp
Offset:
4
Effective address:
contents($sp) + 4MIPS Branch Offset Calculation
Conditional branch instructions such as BEQ and BNE contain a signed 16-bit offset measured in words relative to the instruction after the branch.
byte displacement =
SignExtend(immediate) << 2
target =
PC + 4 + byte displacement
Because the calculator does not know the actual address of the instruction,
it reports the displacement relative to PC + 4.
MIPS J-Type Instruction Format
31 26 25 0
+----------+-----------------------------------------+
| opcode | target[25:0] |
+----------+-----------------------------------------+
6 bits 26 bitsJ and JAL use pseudo-direct addressing. The 26-bit field is shifted left by two positions and combined with upper address bits derived from PC + 4.
MIPS Jump Target Formula
jump_low_28 =
target_field << 2
full target =
(PC + 4)[31:28] |
jump_low_28Without the instruction's PC address, the decoder can reliably report the encoded low 28-bit target component but cannot invent the upper four bits.
MIPS Register Numbers and Names
| Number | Name | Common Role |
|---|---|---|
| 0 | $zero | Constant zero |
| 1 | $at | Assembler temporary |
| 2–3 | $v0–$v1 | Return values |
| 4–7 | $a0–$a3 | Arguments |
| 8–15 | $t0–$t7 | Temporaries |
| 16–23 | $s0–$s7 | Saved registers |
| 24–25 | $t8–$t9 | Temporaries |
| 28 | $gp | Global pointer |
| 29 | $sp | Stack pointer |
| 30 | $fp / $s8 | Frame pointer / saved register |
| 31 | $ra | Return address |
Example: JR $ra
Instruction:
0x03E00008
Opcode:
0
rs:
31 → $ra
funct:
0x08 → JR
Decoded:
JR $raThis is a commonly seen function-return pattern in classic MIPS code.
MIPS Little-Endian Instruction Bytes
A 32-bit instruction is often shown as one hexadecimal word, but on a little-endian MIPS system its bytes appear in reverse significance order in memory.
Instruction:
0x012A4020
Little-endian bytes:
20 40 2A 01Select Little-Endian Bytes when analyzing a raw memory dump containing bytes in that order.
Example: ADDI
Instruction:
0x2128000A
Opcode:
001000 → ADDI
rs:
$t1
rt:
$t0
Immediate:
10
Decoded:
ADDI $t0, $t1, 10Example: LUI
LUI loads the 16-bit immediate into the upper half of the target register.
LUI $t0, 0x1234
Resulting value contribution:
0x12340000The lower sixteen bits are cleared by the LUI operation.
MIPS Instruction Decoder Scope
The opcode space contains instructions from multiple MIPS revisions and extensions. This tool prioritizes common classic integer instructions used in education, disassembly, embedded firmware and basic machine-code analysis.
MIPS Instruction Decoder FAQs
How many bits is a MIPS instruction?
How many bits is the MIPS opcode?
What are the three basic MIPS instruction formats?
What does opcode 0 mean in MIPS?
What is the funct code for ADD?
What is the funct code for SUB?
What is register 29 in MIPS?
What is register 31?
How is a MIPS branch target calculated?
Why can't the decoder give a full J instruction address?
Does ANDI sign-extend its immediate?
Does LW use a signed offset?
Can I enter little-endian MIPS bytes?
Does this decoder support every MIPS extension?
Decode MIPS Machine Instructions
Enter one 32-bit MIPS instruction to inspect its assembly operation, opcode, register fields, function code, shift amount, immediate value, branch displacement, jump target bits and little-endian byte representation.