Question

For example, I want to move a DWORD value in a register into a memory location typed WORD, but am getting errors:

mov [arr + eax*TYPE arr], edx ; error: operands must be same size

the [] brackets dereference to an array element of type WORD.

I've tried doing this as well:

    mov dx, edx ; error: operands must be same size.     
    mov [arr + eax*TYPE arr], dx 

Also no luck trying to use PTR:

mov dx, WORD PTR edx ; error: invalid use of register 

OR

 mov WORD PTR [arr + eax*TYPE arr], edx ; error: invalid use of register 

OR

mov [arr + eax*TYPE arr], WORD PTR edx ; error: invalid use of register

Solution? Thanks for any help!

Was it helpful?

Solution

The register DX is actually the lowest 16 bit of the 32 bit register EDX. You don't need to mov dx, edx because DX is already there. So you simply need to store DX in the word sized variable:

mov  [word_variable], dx

Of course the highest 16 bit of edx will be lost in such a transfer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top