Search code examples
x86attmov

x86 simple mov instruction


This is a simple question but I can't find reliable answers on google.

What does this instruction mean:

movl %eax, (%esi, %ecx, 4)

Is it move the value at register eax to the value in memory that (%esi, %ecx, 4) is pointing too?

(%esi, %ecx, 4) is for an array. So it means Array[Xs + 4i] where Xs is the starting point in memory for the Array and i is just an offset in the integer array.


Solution

  • Exactly correct. This is AT&T syntax, so the source comes first, then the destination. Thus, it stores the contents of the eax register to the memory location esi + 4*ecx.

    If you like to think of this as an array, it stores eax to the ecxth entry of an array of 4-byte objects based at esi.