mips
mips
Introduction to MIPS
MIPS Architecture
MIPS follows the RISC principle, which means it uses a small, fixed set
of instructions that execute in a uniform amount of time. This enables
faster execution and simplifies hardware design, as there is less
complexity in handling instructions compared to Complex Instruction Set
Computing (CISC) architectures like x86.
Data memory stores the values used and produced by the program.
Load and store instructions access this memory to retrieve or save
data, respectively, during the memory access stage.
6. Two Adders:
Pipeline Stages
The MIPS pipeline consists of five stages, each handling a specific part
of the instruction execution process.
The systematic division of tasks across these five stages ensures that
multiple instructions can be executed concurrently, maximizing efficiency
and throughput.
1. Arithmetic Instructions
a. Add
b. Subtract Unsigned
c. Add Immediate
d. Add Unsigned
● Input Values:
○ $2 = 15
○ $3 = 10
● Calculation:
15×10= 150=(10010110)
● Result:
○ The value 150 fits within 32 bits.
○ $1 = 150 (no overflow occurs).
→ Here, the result exceeds 32 bits, and the upper bits are stored in the
Hi Register.
● Example:
○ mult $2, $3
● Input Values:
○ $2 = 100,000
○ $3 = 50,000
Calculation:
100,000×50,000=5,000,000,000
5,000,000,000=0000000100100100011110010000000000000000(64 bits)
f. Division
Example
Input Values:
● $2 = 20 (dividend)
● $3 = 6 (divisor)
Result Storage:
2. Logical Instructions
a. Bitwise AND
b. Bitwise OR
c. AND Immediate
● Example:
○ Let $2 = 150 and the immediate value 100 (binary 01100100).
○ $2 = 150 in binary is 10010110, and 100 is 01100100.
○ After execution: $1 = $2 & 100 = 10010110 & 01100100 =
00000100 (binary).
○ In decimal: $1 = 4.
d. OR Immediate
○ In decimal: $1 = 5120.
3. Branch Instructions
a. Branch on Equal
● Example:
○ Let $1 = 50 and $2 = 2000.
○ The instruction will store the value 50 from register $1 into
memory at address 2000.
c. Jump (J)
● Instruction: j 0x00400020
● Explanation: Jumps to the address 0x00400020 unconditionally.
→ Jumps to a specified address.
● Example:
○ This instruction will set the Program Counter (PC) to
0x00400020 and continue execution from that address.
● Instruction: jr $ra
Registers in MIPS
Significance of CPI
Where:
Example Calculation
Program Details:
CPI= 2.5 ,This means, on average, the processor takes 2.5 cycles per
instruction .