Logo
Articles Compilers Libraries Books MiniBooklets Assembly C++ Linux Others Videos
Advertisement

Article by Ayman Alheraki on January 11 2026 10:37 AM

MIPS architecture

MIPS architecture

  • General-Purpose Registers

  • Special-Purpose Registers

  • Condition Flags

  • Instruction Formats

  • Instruction Encoding with Hexadecimal Examples


General-Purpose Registers (GPRs)

MIPS architecture features 32 general-purpose 32-bit registers, each serving specific conventions:skills.microchip.com+5Imperial College London+5Wikipedia+5

RegisterNameUsage
$0zeroConstant zero
$1atAssembler temporary
$2–$3v0–v1Function return values
$4–$7a0–a3Function arguments
$8–$15t0–t7Temporary registers
$16–$23s0–s7Saved registers
$24–$25t8–t9Temporary registers
$26–$27k0–k1Reserved for OS kernel
$28gpGlobal pointer
$29spStack pointer
$30fpFrame pointer
$31raReturn address

 

Note: Register $0 is hardwired to zero and cannot be modified. Imperial College London+1Wikipedia+1


Special-Purpose Registers

RegisterDescription
HIStores the high-order 32 bits of multiplication/division results
LOStores the low-order 32 bits of multiplication/division results
PCProgram Counter, holds the address of the next instruction
EPCException Program Counter, stores the address to return to after an exception
StatusContains flags indicating the processor's state

 


Condition Flags

Unlike some architectures, MIPS does not have a dedicated condition flags register. Instead, conditional operations are performed using instructions that set registers based on comparisons. For example:

  • Set on Less Than (slt): Sets a register to 1 if one register is less than another; otherwise, sets it to 0.

 

  • Branch if Equal (beq) and Branch if Not Equal (bne): Used for conditional branching based on register comparisons.

 

Note: Floating-point comparisons utilize the Floating Point Condition Codes (FCC) within the Floating Point Control Register (FCSR).


Instruction Formats

MIPS instructions are 32 bits wide and follow three primary formats:

R-Type (Register)

Used for arithmetic and logical operations.

FieldBitsDescription
opcode6Operation code (always 0 for R-type)
rs5Source register 1
rt5Source register 2
rd5Destination register
shamt5Shift amount (used in shift instructions)
funct6Function code specifying the exact operation

 

I-Type (Immediate)

Used for operations with immediate values and memory access.

FieldBitsDescription
opcode6Operation code
rs5Source register
rt5Destination register
imm16Immediate value or address offset

 

J-Type (Jump)

Used for jump instructions.

FieldBitsDescription
opcode6Operation code
address26Target address

 


Instruction Encoding with Hexadecimal Examples

Below are examples of MIPS instructions along with their binary and hexadecimal representations:

Example 1: add $t0, $t1, $t2

  • Description: Adds the contents of registers $t1 and $t2, stores the result in $t0.Users CS Utah

  • Binary Encoding:

 

  • Hexadecimal: 0x012A4020

Example 2: lw $t0, 32($s3)

  • Description: Loads a word from memory address obtained by adding 32 to the contents of $s3 into $t0.

  • Binary Encoding:

 

  • Hexadecimal: 0x8E680020

Example 3: j 0x00400000

  • Description: Jumps to the address 0x00400000.

  • Binary Encoding:

 

  • Hexadecimal: 0x08010000


AI and SIMD Extensions

MIPS architecture includes support for SIMD (Single Instruction, Multiple Data) operations through extensions like MIPS DSP and MIPS SIMD Architecture (MSA). These extensions introduce additional instructions and registers to handle parallel data processing, beneficial in AI and multimedia applications.

For instance, MSA provides 128-bit vector registers and instructions for operations like vector addition, subtraction, and multiplication.

Note: The availability and specifics of these extensions depend on the MIPS processor variant in use.

Advertisements

Responsive Counter
General Counter
1001629
Daily Counter
829