Is it possible to calculate an address by using the indexed addressing mode syntax and store it into a register? Something like the following (wrong) expression (in AT&T assembly syntax):
movl $dataarray(,%edi,8), %eax
I know that the indexed addressing mode can be used to move data:
movl dataarray(,%edi,8), %eax
However, in this case, what I want to do is to store the address of the element of dataarray
indexed by %edi
into the %eax
register.
As already suggested in this comment, the
lea
instruction can be used for that purpose:This way, the address (and not the value at that address, as it occurs with the
mov
instruction) is computed and stored into theeax
register.