| 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 |
val+1 is fine in the following code, but val-1 is not.
|
|
| 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) |