MIPS Memory Addressing Modes


The MIPS is a load/store machine—all values must be moved into the CPU from memory and placed into one of the general purpose registers before it can be used. The memory location of a value, as specified by the addressing mode, is called its effective address (EA). The table below summarizes the three addressing modes available in the MIPS processor.

Mode Syntax Effective Address
Relative relocatable symbol ± expression EA = relocatable address ± expression
Register indirect ($n) where $n: general purpose register n EA = [$n] = contents of $n
Base offset($n) EA = [$n] + offset
Relative Addressing Mode
Address of operand is the relocatable address of a symbol added or subtracted by the value of an expression. Note that (the instructor believes) the MARS and Spim are not able to handle the expression subtracted; e.g., val+1 is fine in the following code, but val-1 is not.
Register Indirect Addressing Mode
Address of operand is contained in a register.

Relative Addressing Mode
     .data
 s:  .asciiz  "abc"
        
     .text
     la  $a0, s+1
     li  $v0, 4
     syscall
       .data
 val:  .byte   1
       .half   2
       .word   3 

       .text 
       lh  $a0, val+1
       li  $v0, 1
       syscall
       .data
 val:  .byte   1
       .half   2
       .word   3 

       .text 
       lb  $a0, val+1
       li  $v0, 1
       syscall
Output Output Output













      I’m late for my best friend’s wedding.    
      Put the pedal to the metal! (drive as fast as possible)