I am a bit confused by addressing modes.
array1 DWORD 200 DUP(?)
If i have this statement:
mov EAX, [EBX + EDI + 10]
EBX is the base, EDI is the index, and + 10 is saying add ten more bytes to EDI? so, EDI would then return 14 bytes long? and return the address and put it into EAX?
Similiarly,
mov EAX, [EBX + EDI * 4]
Is this saying that at what ever index in the array, returns 4 bytes long? Because the array is 4 bytes long for each index right? I guess im not understanding what * 4 does!
in addition,
mov ECX, 100 ; loop counter
mov ESI, 0
top1:
mov [array1 + ESI * 4], ECX
inc ESI
loop top1
This would be putting the number 100 into the array starting at index zero 4 bytes big? So, index[0] = 100, index[1]= 101, index[2]= 102?
Thank you
mov EAX, [EBX + EDI + 10]
Take the value in EBX
and add the value in EDI
and add 10, then use this result as an address to load a 32-bit value into EAX
.
mov EAX, [EBX + EDI * 4]
Take the value in EBX
and add to it 4 times the value in EDI
, then use the result as an address to load a 32-bit value into EAX
.
The last one stores a decreasing sequence of numbers starting at 100 into the memory locations starting at array1
. ECX
is decremented every time the loop
instruction executes, until it reaches 0. The address each progressive value of ECX
is stored at is array1
plus 4 times ESI
, which is incremented on every iteration.