Overview of MIPS ISA: Instruction Formats
Overview of MIPS ISA: Instruction Formats
Discussion
- 04
Overview of MIPS ISA
MIPS is an acronym for Microprocessor without Interlock Pipeline Stages. MIPS is very popular microprocessor
in embedded devices. Salient features of its ISA are described below:
All instructions are 32-bit wide (fixed-length instructions)
o Fixed-length instructions are easy to decode (simple decoding logic and hence fast decoding) as
opposed to variable-length instructions
o With fixed-length instructions, it’s easy to generate address of next instruction to be fetched. (address
of next instruction = PC + instruction-length)
o The downside of fixed-length is poor storage economy as opposed to variable-length instructions that
use as much storage as required.
MIPS is a byte-addressable machine that means every byte has a unique address.
Address are 32-byte wide
There are 32 general-purpose registers each of size 32-bit
These features are examples of a design principle: simplicity favors regularity. Simple designs are usually
fast and easy to debug and improve.
Instruction Formats
An instruction format is a breakup of instruction into different fields, each field being reserved for a specific
purpose. MIPS has three instruction formats (the lesser the number of instruction formats, the simpler the ISA
will be)
1. R (Register) Format
This divides the instruction into six fields as follows:
6 5 5 5 5 6
op rs rt rd shamt funct
Where,
op = opcode
rs = identifier of first source register
rt = identifier of second source register
rd = identifier of destination register
shamt = shift amount indicating how many times a register must be shifted left or right (only
used in shift instructions)
funct = distinguishes among R-type instructions as all R-type instructions have op = 0.
Example:
add $1, $2, $3
The machine encoding of this instruction will be as follows:
0 2 3 1 0 32
Page - 1 - of 3
Parallel Processing
Discussion
- 04
All arithmetic/logic instructions in MIPS are 3-address instructions i.e. they need to specify three operands.
Hence, MIPS is a 3-address machine. No arithmetic/logic instruction is allowed to have a memory location as
one of the operands i.e. only registers or in some instructions one immediate operand is allowed. Hence,
MIPS is a register-register architecture.
2. I (Immediate) Format
This divides the instruction into four fields as follows:
6 5 5 16
op rs rt Immediate/offset
This instruction adds 25 to the contents of register $2 and stores the result in $1. The machine encoding of
this instruction will be as follows:
8 2 1 25
Please note that here rt is interpreted as a destination register rather than a source register.
sw $1, 40($2)
This instruction does the reverse of lw. Specifically, it stores a word from a CPU register ($1 in this example)
into memory at the address given by $2 + 40 The RTL description of the instruction follows:
Mem [$2 + 40] $1
The machine encoding of this instruction will be as follows:
43 2 1 40
In MIPS only load/store instructions are allowed to access memory. No other instruction can access memory.
Such an architecture is called load-store architecture. You must appreciate that load-store architecture =
register-register architecture.
All RISC (Reduced Instruction Set Computers) use load-store architecture. What’s reduced in a RISC?
Instruction formats, addressing modes, number of instructions, virtually everything except a large set of
Page - 2 - of 3
Parallel Processing
Discussion
- 04
general-purpose CPU registers. RISC is actually based on the philosophy: less is more. This is in contrast to
the design philosophy of CISC (Complex Instruction Set Computers). MIPS is an example of RISC machine
Example 3: Branch Instruction
There are two types of branch instructions in the MIPS:
1. beq $1, $2, 25
This compares contents of $1 and $2 and transfers control to (i.e. jumps to) an instruction (called
target instruction) located at the following address:
BTA (branch target address) = (PC + 4) + offset x 4
Where PC contains the address of branch instruction. In this example, the offset is 25. This offset is
signed (2’s complement notation) expressed in words to increase the branching distance.
The machine encoding of this instruction will be as follows:
4 1 2 25
******
Page - 3 - of 3