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.
Asked
Active
Viewed 27 times
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. – 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 Answers
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:
- Why does the lw instruction's second argument take in both an offset and regSource?
- What is the minimum instruction set required for any Assembly language to be considered useful? (note the difference between useful and Turing-complete.)

Peter Cordes
- 328,167
- 45
- 605
- 847