Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Visual Studio assemble mov eax, [edx][ebx][ecx][edi] without complaint?

Tags:

x86

assembly

masm

In Visual Studio, I wrote:

mov eax, [edx][ebx][ecx][edi]

But it assembles just fine.

Why it is not invalid effective address?

like image 492
pawel_bolak Avatar asked Nov 08 '15 16:11

pawel_bolak


People also ask

What does MOV EAX EBX do?

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.

What is MOV EDX in assembly language?

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 .

What is EAX and EBX in assembly?

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.

What does ECX mean in assembly?

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.


1 Answers

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.

like image 148
Ross Ridge Avatar answered Oct 15 '22 12:10

Ross Ridge