News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

"error A2022" bug? (with EAX)

Started by Broken Sword, November 09, 2005, 08:04:40 PM

Previous topic - Next topic

Broken Sword

Hi guys. What's wrong with mov reg, [EAX...] constructions ?
"error A2022: instruction operands must be the same size" is displayed in all cases we use "EAX" in the right part.

ramguru

You're pointing to memory and therefore must specify what you want from it byte word dword
mov eax, dword ptr [eax]
mov ax, word ptr [eax]
mov al, byte ptr [eax]

mnemonic

Hello,

how about a real life example?

Quote from: Robert on November 09, 2005, 08:04:40 PM
Hi guys. What's wrong with mov reg, [EAX...] constructions ?
"error A2022: instruction operands must be the same size" is displayed in all cases we use "EAX" in the right part.

If you code:
mov dx, eax;
The error is legitimate because you are trying to mov 32bit into a 16bit destination.
You must use a 32bit register as destination register in that case.

Also refer to the above post if you are dealing with pointers.
Take care on the size. Assembler is not happy about "implict things"  :wink
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Broken Sword

:) thanks guys, but i'm not so lame in MASM...

look:

mov eax, [ebx+0Ch] ; no error
mov ecx, [edx*2+4] ; no error
mov ebx, [eax+4] ; error A2022!!!

understand? ;)


mnemonic

Quote from: Robert on November 09, 2005, 09:05:41 PM
look:

mov eax, [ebx+0Ch] ; no error
mov ecx, [edx*2+4] ; no error
mov ebx, [eax+4] ; error A2022!!!

understand? ;)

Thats why I asked for an example. Figuring something out isnĀ“t really good...

BUT:

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib kernel32.lib
include \masm32\include\user32.inc
includelib user32.lib

.data
MsgCaption      db "Iczelion's tutorial no.2",0
MsgBoxText      db "Win32 Assembly is Great!",0

.code
start:
      push ebx
      push eax
      mov eax, offset MsgCaption
      mov ebx, [eax+4]
      pop eax
      pop ebx
invoke MessageBox, NULL,addr MsgBoxText, addr MsgCaption, MB_OK
invoke ExitProcess,NULL
end start


The above example assembles, links and executes just fine...

Quote from: Robert on November 09, 2005, 09:05:41 PM
:) thanks guys, but i'm not so lame in MASM...
Really?

Regards
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Broken Sword

Holly Christ... It was my mistake... I've forgot 'bout

assume reg:nothing

before using

mov ..., [reg...] constructions.

nice nolame bug :)

Reggards.