Reputation: 149
I have a piece of small code and I can't understand what line 3 does. Can anyone help me to explain it. Many thanks.
mov ebx, pointer1 //Assign of pointer pointer1 value to ebx
movzx eax, byte ptr[esi] //Get value from pointer address esi and assign to eax
mov dx, [ebx + eax * 2] //??? Dont know what it does
mov [edi], dx
As I guess, If [ebx]
is a byte array, that line will take array[eax_value]
and array[eax_value+1]
?
Upvotes: 1
Views: 88
Reputation: 22074
Pointer1 is a pointer to a short int
(16 bits) array. esi
is pointing to some byte value which is an index in the array.
So the pointer is loaded to ebx
, then the index is loaded into eax
and multiplied by 2 (because of the 16 bit data size) and added as an offset to the array pointer.
The value from the array is copied to wherever edi
is pointing to.
Upvotes: 3
Reputation: 5211
ebx holds a pointer value to pointer1. eax is used to offset into it. You are taking the nth 16bit value from pointer1 where n is determined by the value read into eax.
Upvotes: 4