MIPS is a family of RISC (Reduced Instruction Set Computing) microprocessor architectures developed by MIPS Computer Systems. MIPS processors are widely used in embedded systems, networking equipment, game consoles, and academic settings due to their simplicity, efficiency, and clean architecture.
RISC Architecture: MIPS follows the RISC (Reduced Instruction Set Computing) design philosophy, which means that it uses a small, simple set of instructions that can execute very quickly, typically in one clock cycle. The goal of RISC is to simplify the design of processors and improve performance by optimizing common tasks.
Fixed-Length Instructions: MIPS instructions are fixed-length (usually 32 bits), meaning every instruction is the same size, which simplifies instruction decoding and pipeline design.
Three Types of Instructions: MIPS instructions are divided into three main formats:
Load/Store Architecture:
MIPS is a load/store architecture, meaning that all operations (like addition or subtraction) happen between registers, and memory can only be accessed using special load and store instructions (e.g., LW for loading a word, SW for storing a word). This reduces complexity and optimizes performance.
Pipelining: MIPS processors are designed to support pipelining, a technique that allows multiple instruction stages (fetch, decode, execute, memory access, and write-back) to be overlapped. This increases instruction throughput and helps achieve high performance.
Register-Based Operations:
MIPS uses a large set of registers. Typically, MIPS architecture has 32 general-purpose registers, numbered $0 to $31. These registers are used to store values temporarily during the execution of instructions.
$0 is a constant register that always contains the value 0.$31 is often used as the return address for function calls.Simple and Clean Design: MIPS processors are known for their simplicity in design, which makes them easy to implement and understand. The clean design also facilitates optimizations like branch prediction, out-of-order execution, and superscalar execution (where multiple instructions are processed per cycle).
MIPS instructions come in three primary formats: R-type, I-type, and J-type. Each type of instruction has a specific format that dictates how the instruction is structured and what operations it can perform.
R-type instructions perform operations between two registers and store the result in a third register. They are used for operations like arithmetic, logic, and shifts.
Format:
opcode (6 bits) | rs (5 bits) | rt (5 bits) | rd (5 bits) | shamt (5 bits) | funct (6 bits)
Example: add $t0, $t1, $t2
$t1 and $t2 and stores the result in $t0.I-type instructions are used for operations that involve an immediate value (a constant) and a register. They are typically used for arithmetic with immediate values, load/store operations, and branches.
Format:
opcode (6 bits) | rs (5 bits) | rt (5 bits) | immediate (16 bits)
Example: addi $t0, $t1, 5
5 to the contents of register $t1 and stores the result in $t0.Example: lw $t0, 4($t1)
4 + $t1, into register $t0.J-type instructions are used for jump operations, which modify the flow of execution. They specify a target address for jumps or branches.
Format:
opcode (6 bits) | address (26 bits)
j for jump).Example: j target
Here are some examples of commonly used MIPS instructions:
Arithmetic Instructions:
add $t0, $t1, $t2: Adds the values in registers $t1 and $t2, stores the result in $t0.sub $t0, $t1, $t2: Subtracts the value in $t2 from $t1, stores the result in $t0.Load/Store Instructions:
lw $t0, 0($t1): Loads a word from memory at the address 0 + $t1 into register $t0.sw $t0, 0($t1): Stores the value in register $t0 into memory at the address 0 + $t1.Branch Instructions:
beq $t0, $t1, label: Branches to label if the contents of registers $t0 and $t1 are equal.bne $t0, $t1, label: Branches to label if the contents of registers $t0 and $t1 are not equal.Jump Instructions:
j target: Jumps to the target address specified by the instruction.Shift Instructions:
sll $t0, $t1, 2: Shifts the value in $t1 left by 2 bits and stores the result in $t0.srl $t0, $t1, 2: Shifts the value in $t1 right by 2 bits and stores the result in $t0.MIPS processors have 32 general-purpose registers ($0 to $31). The registers are used for different purposes, and some are reserved for specific roles in the architecture.
0.$t0 to $t7).$s0 to $s7).$t8 and $t9).MIPS architecture
Open this section to load past papers