m
is a pointer passed on the stack. The assembler will turn m
into something like [ebp+8]
. Indexing will access items on the stack, starting from that position and that's not what you want. You need to dereference the m
pointer which you can only do if you load it into a register.
mov ecx, m ; this will be mov ecx, [ebp+8] or similar
mov eax, [ecx + 0*4] ; first item
call WriteInt
mov eax, [ecx + 1*4] ; second item
call WriteInt
...
I do not recommend beginners use fancy features of their assembler without understanding what code gets generated exactly.