In Visual Studio, I wrote:
mov eax, [edx][ebx][ecx][edi]
But it assembles just fine.
Why it is not invalid effective address?
mov [eax], [ebx] would mean "move the contents of the memory location pointed to by ebx to the memory location pointed to be eax . That is a memory-to-memory move, which Intel does not support.
mov [edx],eax stores the value of eax in memory, to the address given in edx (in little-endian byte order). mov eax,[edx] does exactly the reverse, reads a value stored from the memory, from the address given in edx , and stores it in eax .
eax, ebx, ecx and so on are actually registers, which can be seen as "hardware" variables, meaning different than higher level-language's variables. Registers can be used in your software directly with instructions such as mov , add or cmp . The leading e means extended that is your register is 32 bits wide.
CX is known as the count register, as the ECX, CX registers store the loop count in iterative operations. DX is known as the data register. It is also used in input/output operations. It is also used with AX register along with DX for multiply and divide operations involving large values.
It appears to be a bug in more recent versions of MASM.
Using the following file as an example:
.586
_TEXT SEGMENT USE32
mov eax, [edx][ebx][ecx][edi]
_TEXT ENDS
END
With MASM 6.11d this generates the following error:
t213a.asm(4) : error A2030: multiple index registers not allowed
With MASM 8.00.50727.42 or more recent there's no error, and the statement assembles to:
00000000: 8B 04 0F mov eax,dword ptr [edi+ecx]
So [edx][ebx][ecx][edi]
is not a valid addressing mode. A bug in the version of MASM you're using is accepting it when it should be rejecting it as an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With