News:

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

Textbook Movzx Code In Error. Need help.

Started by devilhorse, October 01, 2008, 01:00:08 PM

Previous topic - Next topic

devilhorse

I am taking an online course in assembly language. In my course material there is a line of code as follows: Movzx Eax, Ecx + Eax * 2

It will not let the program compile and gives me an error message invalid use of register. I consulted the Intel Opcode manual and I understand that with this opcode I have a choice of doing the following actions:

Move byte to word with zero-extension
Move byte to doubleword, zero-extension
Move word to doubleword, zero-extension

The line of code I have highlighted in red above does not fit any of this criteria. I have contacted the instructor and he insists it should compile.

I am asking if someone could please show me how to re-write this code so that it will acheive the same result as intended and compile without error.

sinsi

movzx eax,byte ptr [ecx+eax*2]
;or
movzx eax,word ptr [ecx+eax*2]

masm expects memory accesses like that to be in square brackets
and because it can be ambiguous (byte/word) you need the size operand (override?)
Light travels faster than sound, that's why some people seem bright until you hear them.

raymond

And you should definitely ask the instructor which assembler he is using, which does not throw an error with that line of code. It would ceertainly help in identifying what he intended that instruction to perform.

All assemblers are NOT the same. Some have totally different ways of handling data.


When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com