I am reading through Programming from the ground up by Jonathan Bartlett. The author discusses memory addressing mode and states that the general form of memory address reference is this:
ADDRESS_OR_OFFSET (%BASE_OR_OFFSET, %INDEX, MULTIPLIER)
where the final address is calculated thus:
FINAL_ADDRESS = ADDRESS_OR_OFFSET + %BASE_OR_OFFSET + MULTIPLIER * %INDEX
.
It is also stated that if any of the pieces is left out, it is just substituted with zero in the equation. ADDRESS_OR_OFFSET
and MULTIPLIER
are required to be constants, while the other elements are required to be registers. These seem to be the only general rules specified.
So far, so good.
The author then discusses indirect addressing mode and gives as example:
movl (%eax), %ebx
which moves the value at address stored in the eax
register into ebx
register.
For that to work, (%eax)
should be interpreted as 0(%eax,0,0)
as opposed to 0(0,%eax,0)
. Is there an additional rule that enforces this interpretation?