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.
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?)
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.