I know the meaning of

mov eax,[ebx]

But what is the meaning of

mov eax,[ebx][esi]


add [ebx][edi],edx

Sometimes, but not always, an error message like "instruction operands must be the same size" appears when building for example

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

The code will be accepted if I add a "dword ptr" like

add [color=blue]dword ptr[/color] [edi],edx
mov eax,[color=blue]dword ptr[/color][ecx]

Why is that so?

Can someone enlighten me on the subject?

Posted on 2003-03-08 13:48:20 by minor28
But what is the meaning of code:
mov eax,


add ,edx

I think that ebx is multiplied by edi. Randy Hyde talks about something like that AOA32 - Integer Arithmetic.

Sometimes, but not always, an error message like "instruction operands must be the same size" appears when building for example

The assembler doesn't know if you want to access a byte, word , dword etc so you have to tell it.
Posted on 2003-03-08 14:27:54 by Odyssey
mov eax,

In masm this is one way of writing complex memory operands of the form (base + index + displacement).
It is equivalent to writing: mov eax, and all this says is to move the dword located at memory address ebx+esi into eax.

"instruction operands must be the same size"
you get this error when :
A: the operands are defined with different sizes or
B: the operand sizes are ambiguos

for example:
mov eax,; this is valid because masm knows the size of eax is 4 bytes so it moves the four bytes pointed to by

mov eax,2: this is also valid for the same reason

mov ,2 ;this is invalid because can be pointing to any sized data, and the value two can also be any size:confused: . Masm can't deduce what sized data the operation is being performed on so it flags an error. You explicity tell masm you are operating on dwords by specifying dword ptr. The valid statement becomes :
mov dword ptr,2 if you meant dwords
mov word ptr,2 if you meant words
mov byte ptr,2 if you meant bytes
Posted on 2003-03-08 14:29:47 by MArtial_Code

OK mov eax, is equal to mov eax,.

If I write this code
mov eax,.e_magic
I assume that esi points to the IMAGE_DOS_HEADER by writing
assume esi:ptr IMAGE_DOS_HEADER
before the mov line.

How about
mov eax,.e_magic
Do I write
assume esi:ptr IMAGE_DOS_HEADER
mov eax,.e_magic
assume esi:ptr IMAGE_DOS_HEADER
mov eax,.e_magic]
or ?

Posted on 2003-03-08 17:02:25 by minor28
The examples which you give are all valid and will do what you want.
I suggest you test it for yourself.
Posted on 2003-03-09 05:22:39 by MArtial_Code
Thanks alot.

Posted on 2003-03-09 06:38:01 by minor28