memory addressing


Summary

Endianness

  • Big-endian -> most significant byte in lowest address
  • Little-endian -> least significant byte in lowest address

affects the order of bytes within a multi-byte word, within the byte nothing changes

Register addressing

  • R-type
  • operand is specified in registers

Immediate addressing

  • I-type
  • operand is specified in the instruction

Displacement addressing

  • I-type - load/store
  • operand is in memory

Concept

Addressing modes

  • ways to specify an operand
Addressing modeExampleMeaning
Registeradd r1, r2r1 <- r1 + r2
Immediateadd r1, 3r1 <- r1 + 3
Displacementadd r1, 8(r2)r1 <- r1 + mem[r2+8]
Register indirectadd r1, (r2)r1 <- r1 + mem[r2]
Indexed/Baseadd r1, (r2+r3)r1 <- r1 + mem[r2+r3]
Direct/Absoluteadd r1, (100)r1 <- r1 + mem[100]
Memory indirectadd r1, @(r2)r1 <- r1 + mem[mem[r2]]
Auto-incrementadd r1, (r2)+r1 <- r1 + mem[r2]
r2 <- r2 + x
Auto-decrementadd r1, -(r2)r2 <- r2 - x
r1 <- r1 + mem[r2]
Scaledadd r1, 100(r2)[r3]r1 <- r1 + mem[100+r2+r3*x]