Edit: I'm using MASM32.
While reading various texts, I've found myself a little confused. Looking over "All About Arrays" (from this site's wiki), I see the following:
If my understanding is correct, the address of "Index" - not the contents - is placed into eax. If that's the case, how can the address be multiplied by another address (ElementSize)?
Perhaps my lack of understanding has to do with addressing modes, but don't the [] designate the value and not the address?
While reading various texts, I've found myself a little confused. Looking over "All About Arrays" (from this site's wiki), I see the following:
ElementSize equ 4 ; Define element size
mov eax,Index ; Get normalized index
imul eax,ElementSize ; Scale it
mov ecx,DwordArray ; Get array value
If my understanding is correct, the address of "Index" - not the contents - is placed into eax. If that's the case, how can the address be multiplied by another address (ElementSize)?
Perhaps my lack of understanding has to do with addressing modes, but don't the [] designate the value and not the address?
It is the value itself, not its address, that is loaded. AFAIK only TASM's ideal mode required sqare brackets to strictly differentiate address references from value references.
So, basically, it goes like this:
1. ElementSize := 4
2. eax := Index
3. eax := Index * ElementSize
4. ecx := 4 bytes starting from memory location pointed by .
So, basically, it goes like this:
1. ElementSize := 4
2. eax := Index
3. eax := Index * ElementSize
4. ecx := 4 bytes starting from memory location pointed by .
Thanks for responding.
So if the value is loaded into eax using mov eax, Index, what does mov eax, load into eax? I would assume the address, if the bracket-less version loads the value, but that's contrary to what I've read so far.
So if the value is loaded into eax using mov eax, Index, what does mov eax, load into eax? I would assume the address, if the bracket-less version loads the value, but that's contrary to what I've read so far.
Both load the contents, it is "mov eax, OFFSET Index" which loads the pointer. Besides TASM, FASM also use "mov eax, Index" for pointer and "mov eax, " for contents and does not understands "offset".
I think I have a better understanding. Thank you.