In X86 assembly, what type of operations use the addressing mode with this format?
IndexReg * ScaleFactor + Offset
mov rax, [r15 * 8 + 56]
Usually with the disp32
being the absolute address of an array, like mov eax, [arr + rdi*4]
, not a small integer constant like your 56
.
This was always possible in 16 and 32-bit mode, but in 64-bit mode only possible for non-PIE code models where static data is in the bottom or top 2GiB of virtual address-space. (See 32-bit absolute addresses no longer allowed in x86-64 Linux? / Mach-O 64-bit format does not support 32-bit absolute addresses. NASM Accessing Array)
Other use-cases include LEA to shift-and-add like lea eax, [rdi*8 + 56]
.
In theory you could use it to iterate through an aligned array where the scaled register holds address/8, perhaps in a loop also using that value as a byte offset into an array of smaller elements like [rbx + rdi]
.
Note that it's only encodeable with a 4-byte disp32
not a 1-byte disp8
(https://wiki.osdev.org/X86-64_Instruction_Encoding#SIB), so the machine-code format doesn't encourage uses like your [r15*8 + 56]
. x86 addressing modes always have a base register and/or a disp32 which could (before 64-bit mode) hold an absolute address of the start of an array.
See Referencing the contents of a memory location. (x86 addressing modes) for example use-cases for every x86 addressing mode. (Although it doesn't try to be exhaustive to cover every way to use each addressing mode.)