Mastering Addressing Modes in MIPS

Michael Aug 03, 2026
What is a Memory Management Unit (MMU)?
What is a Memory Management Unit (MMU)?

Addressing modes in the Microprocessor Without Interlocked Pipeline Stages (MIPS) architecture play a crucial role in determining how the processor fetches and manipulates data. They specify the direction of data transfer between memory and registers, and register to register. Understanding these modes is essential for writing efficient MIPS assembly code.

What is a Memory Management Unit (MMU)?
What is a Memory Management Unit (MMU)?

The MIPS architecture supports three primary addressing modes: direct, indirect, and immediate. Each mode serves a unique purpose in data manipulation and retrieval.

Sensory Disorder, Asd Symptoms Women, What Is Neurodiverse, Boost Self-esteem For Neurodivergent Individuals, What Does Neurodiverse Mean, Food Sensory Issues, Spectrum Disorder, Understanding Neurodiversity In Education, Understanding Neurodiverse Orientations
Sensory Disorder, Asd Symptoms Women, What Is Neurodiverse, Boost Self-esteem For Neurodivergent Individuals, What Does Neurodiverse Mean, Food Sensory Issues, Spectrum Disorder, Understanding Neurodiversity In Education, Understanding Neurodiverse Orientations

Direct Addressing Mode

The direct addressing mode operates on a fixed memory address directly given in the instruction. It is also known as immediate mode. In this mode, the data is directly provided in the instruction itself.

The N by M Problem: Why MCP Exists
The N by M Problem: Why MCP Exists

The direct addressing mode is typically used for loading a constant value into a register. For instance, the instruction 'li $t1, 10' loads the value 10 into the register $t1 using the direct addressing mode. The 'li' stands for 'load immediate', indicating that the value is directly loaded from the instruction.

Direct Addressing Mode with Register

Sideloadly Not Detecting Device
Sideloadly Not Detecting Device

In some instructions, the direct addressing mode can also specify a register. This is particularly useful when we want to load a specific value into a register or use a constant value in an arithmetic operation.

For example, 'addi $t1, $t2, 10' adds 10 to the value in register $t2 and stores the result in $t1. Here, '10' is treated as an immediate value, and the 'addi' instruction indicates that the operation is immediate (direct).

Drawbacks of Direct Addressing Mode

What is Real Mode?
What is Real Mode?

While the direct addressing mode is simple and fast, it also has its limitations. The main drawback is that the value is fixed in the instruction. If the value needs to be changed, the entire instruction needs to be replaced, leading to inflexibility.

Moreover, for larger immediate values, the instructions become longer, which can lead to inefficient use of memory. This is less of a concern in MIPS, which uses 32-bit words, but it's something to consider in architectures with smaller word sizes.

Indirect (Register) Addressing Mode

a blue and green poster with information about the different types of internet services on it
a blue and green poster with information about the different types of internet services on it

The indirect addressing mode, also known as register mode, uses a register to hold the memory address. The data is then fetched from the memory location pointed to by the register.

The 'lw' (load word) instruction in MIPS uses the indirect addressing mode. 'lw $t1, ($t2)' loads the word (4 bytes) at the memory address stored in the $t2 register into the $t1 register. The parentheses around '($t2)' indicate that the contents of $t2 are to be used as an address.

Unmasking the Invisible Struggle: Recognizing the Signs of a Dysregulated Nervous System in Moms
Unmasking the Invisible Struggle: Recognizing the Signs of a Dysregulated Nervous System in Moms
TIP: New Way to Get Rid of “AI Mode” Button in Google Chrome
TIP: New Way to Get Rid of “AI Mode” Button in Google Chrome
A Beginner’s Guide to OSINT Investigation with Maltego
A Beginner’s Guide to OSINT Investigation with Maltego
a man sitting in front of a laptop computer on top of a desk with icons above it
a man sitting in front of a laptop computer on top of a desk with icons above it
a table with different clocks and times on each one side, including the same time
a table with different clocks and times on each one side, including the same time
Behavior Intervention Plans: A Complete Guide 📖
Behavior Intervention Plans: A Complete Guide 📖
Email on Easy Mode: 10 Email Business Templates for Womenpreneurs
Email on Easy Mode: 10 Email Business Templates for Womenpreneurs
two iphone screens showing the same user's profile
two iphone screens showing the same user's profile
Incognito mode won't keep your browsing private. Do this instead
Incognito mode won't keep your browsing private. Do this instead
Incognito mode makes me invisible
Incognito mode makes me invisible

Indirect Addressing Mode with Offset

Sometimes, we want to access data that is at an offset from the address stored in a register. The MIPS architecture allows for this with the 'lw' instruction. 'lw $t1, 4($t2)' loads the word at the address that is 4 bytes (1 word) higher than the address in the $t2 register.

This is particularly useful when the exact address of the data is not known, but it can be calculated relative to some base address stored in a register.

Benefits and Drawbacks of Indirect Addressing Mode

One of the primary benefits of the indirect addressing mode is flexibility. If the address needs to change, only the contents of the register need to be modified, not the entire instruction.

However, it also has its drawbacks. The memory address needs to be loaded into a register first, which adds an extra instruction and can slow down the execution. Also, if not used correctly, it can lead to direct memory access, which can cause runtime errors.

In conclusion, addressing modes in MIPS provide a rich set of tools for data manipulation. The direct mode is simple and fast but lacks flexibility, while the indirect mode is flexible but requires extra instructions. Understanding these trade-offs is key to writing efficient MIPS code. Happy coding!