For accessing arrays, I have the seen the following two notations used quite often:
# Addressing in the general form of:
# address_or_offset(%base_or_offset, %index, scale)
# (1) using a label, which resolves to an address
movzwq myarray(, %rdi, 2), %rbx # 0x400078
# (2) using an offset based on a register, usually %rbp
movzwq -8(%rbp, %rdi, 2), %rcx
In the first form it uses the notation of address(offset, index, scale)
and in the second it uses the notation of offset(base, index, scale)
. My question is whether it is every practical to use the first notation with including an index register, something like:
movzwq myarray(%r11, %rdi, 2), %rbx
Of is that never used, and it's just always left blank (like in the first example) when using that address(, index, scale)
notation?
Finally, is offset/base
and address/offset
just two ways of doing the same thing, that is, it allows arriving at start memory location by doing an offset from a register in the first case and from an address/label in the second case?