This is some partial code , after a call to a function .
movl 12(%ebp),%ecx
movl 8(%ebp),%esi
movl (%esi,%ebx,4),%edx
This is the corresponds C function :
void foo(MyType_t A[], int n);
So basically , %esi is A[] , and %ecx is n
What does the 3rd line means ? please note that the left operand has 3 sub-operands .
%edx = A[4 * %ebx + %esi] ?
Regards
is AT&T syntax for “scale, index, base” (SIB) addressing.
%esiis the base address,%ebxis the index, and 4 is the “scale” (the multiplier applied to the index to generate a byte offset to the base address).(The equivalent Intel syntax equivalent is more explicit:
mov edx, dword ptr [esi+ebx*4].)Probably not, because the effective address calculation in this addressing mode works in units of bytes, whereas C array indexing works in units of the size of an array element.
If
%esiis the base address ofAin memory, and%ebxisn, and the size of a single element ofA(i.e.sizeof(MyType_t)) is 4, then%esi + %ebx * 4gives the address ofA[n]; so the instruction would mean%edx = A[n]in that case.