Addressing Modes
Memory addresses can be given by
- symbolic name (label) (effectively, a constant)
- indirectly via a register (effectively, pointer dereferencing)
Examples:
prog:
a: lw $t0, var
b: lw $t0, ($s0)
c: lw $t0, 4($s0)
d: lw $t0, vec($s1)
e: lw $t0, vec+4
|
If $s0 contains 0x10000000 ,$s1 contains 0x00000008 , &var = 0x100000008 and &vec = 0x10000000C
- computed address for
a: is 0x100000008
- computed address for
b: is 0x100000000
- computed address for
c: is 0x100000004
- computed address for
d: is 0x100000014
- computed address for
e: is 0x100000010
|