This question already has an answer here:

In the following picture the line i want to mention is:

mov [esp+eax*4+0Ch], edx

Here eax is the index in the array. But, where is the address of the array to access?

what does mean this line of code ? (0Ch)

Full context of the asm line

marked as duplicate by 0xC0000022L Jul 11 '18 at 18:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Usually, when running through an array, we can find the following lines of assembly code:

mov [base_address_of_array + array_index * size_of_an_item_in_array], edx

In your case, my guess would be that the array is on the stack (that is why you find esp as part of the base address of the array. Then, you also have an offset to esp which is 0Ch (which is 12 in decimal). So, the array is located at esp + 0Ch. Then, eax is the index and 4 is the size of an item in the array (probably an integer of 4 bytes).

If we look at the whole CFG, I would translate it back to C in something like this:

int array[4];

for (int i = 0; i < 4; ++i)
  array[i] = i;

Note: I supposed that the blue arc in the CFG is getting back to loc_401381.

  • The assembly code looks like pointer arithmetic with arrays. Isn't it? – Biswapriyo Sep 4 '18 at 4:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.