0

Can an array be implemented using only indirect addressing mode? I think we can only access the first element but what about the other elements? For that, I think, we'll have to use immediate addressing mode.

Curious
  • 43
  • 8
  • An `add` instruction can generate an address in a register. A CPU with only `[register]` addressing modes would work, but need more instructions than one with an immediate displacement as part of load/store instructions. – Peter Cordes Feb 23 '18 at 18:09
  • @PeterCordes, yes I was also thinking so. Kindly add it as an answer. – Curious Feb 23 '18 at 18:43

1 Answers1

0

An add instruction can generate an address in a register.

A CPU with only [register] addressing modes would work, but need more instructions than one with an immediate displacement as part of load/store instructions.

Instruction set design isn't about what's necessary for computation to be possible, but rather about how to make it efficient.

related:

Peter Cordes
  • 286,368
  • 41
  • 520
  • 731