# help me to understand array? Question #1 is the `lea edx, [esp+24]` start of array ? and `eax, [esp+140]` index?

then whats `add eax, edx` doing here and this source code mean ? can you please explain?

I am confused about array and indexing an array in assembly. here are few screen shot. Please help me understand how this array works ? how it indexed and so on. • please spend some time editing this post so it's a bit more polished. Not sure if this link with number 4 at the end of the post is valid or a mistake. Jun 4 '18 at 16:11
• I'm with Paweł. Please make sure specifically not to include purely screenshots. The first and second screenshot could easily be replaced by a code block, which would aid search engines trying to index our site. The reason I ask you to do it, is because you only have to copy & paste. However, I or anyone else would have to sit down and type down what's seen on the screenshots. Jun 6 '18 at 10:03

the first screen shot shows

``````cmp al,59h
``````

59h is ==

``````C:\\>python -c "print '%c' % 0x59"
Y
``````

so it should correspond to your if clause (if ch[i] == 'Y')

then that means

the previous line in your source code is a for loop whose counter variable i is represented by mov eax , [esp+140]

it should have been initialized to 0 some where earlier in the block

edx is the start of the the array (possibly 8 bit size) ch
it is a pointer an address like 0x401234 in this line
assuming 0x401234
then the array would be accessd by
0x401234+0 , +1 , +2 , +3 , +4 ,+5 ..... until the maximum value g (not shown in your screen shot )

the movzx line in your screen shot access the underlying variable ch[i] or *(byte / char / type *) (0x401234 , ..5 , ..6 ,..7 , --so on until 0x401234+g )

so the array would be accessed like this (esp+140) would be incremented at the end of for loop iteration each time

``````0x401234 = 'Y' (edx = 401234 + ( eax = [esp+140] == 0 )) = *(char *)0x401234
0x401235 = 'Y' (edx = 401234 + ( eax = [esp+140] == 1 )) = *(char *)0x401235
0x401236 = 'Y' (edx = 401234 + ( eax = [esp+140] == 2 )) = *(char *)0x401236
..... until 0x401234+g
``````