So if I have a procedure where the first formal parameter is an int[] and I’m enumerating through that loop, I’m confused about why one piece of code works where another doesn’t. I should be able to do this:
#where ebp+8 is the location of the pointer, and ecx is the counter
mov edx, [ebp+ecx*4+8]
This gives me a gibberish value for edx, but this code works fine
mov edx, [ebp+8]
mov edx, [edx+ecx*4]
I don’t understand the difference between those statements.
They are different:
In the first code:
You are loading from the address:
ebp+ecx*4+8In the second code:
You first load the value stored at
ebp+8. Then you use it as the base address for the second load.In other words, the base address is stored at the memory location pointed to by
ebp + 8. It is not actually stored in theebpregister itself.