These are the 4 lines of assembly code. i am trying to understand them. (It is intel syntex.)
– mov eax, ebx
– mov eax, [ebx]
– mov eax, [ebx+ecx*X] (X=1, 2, 4, 8)
– mov eax, [ebx+ecx*X+Y] (Y= one byte, 0-255 or 4 bytes, 0-2^32-1)
1)The first line will copy whatever the value in ebx register to eax register. 2)The second line will find whatever the value in ebx register, teat it as a memory address, will go to that memory address. It will copy the value in that memory address to eax register. 3)The third line will get the value on ebx register, treat it as a memory address. Add ecx*X to it and will get a new address, and then go to this new address and get the value and copy it to eax. 4)I can't get the 4th line.
Can anyone just check, what I understood about the instructions are correct? If they are not correct, kindly explain me. Also explain the 4th line too.
Thanks in advance.
Your assumptions look correct to me.
It's the same as the 3rd one, except that an absolute offset is added. For example:
If you set
ebx
to 0 you'd read theecx:th
element ofarray1
. If you setebx
to 16 (4 * sizeof(dword)) you'd read theecx:th
element ofarray2
.