MMX error A2022:instruction operands must be the same size

1.6k views Asked by At

I'm trying to handtune a piece of code(a function originally writen in C++) and the assembler throws this error: error A2022:instruction operands must be the same size

at the lines that use the 'movq' instruction.

The code:

.686P       
.mmx          
.xmm           
.MODEL flat, stdcall
.STACK 4096

.data
packedbytes db 10, 20, -30, 40, 50, 60, -70, 80
packedwords dw 10, 20, 30, 40
packeddwords dd 10, 20

.code
main PROC 

    movq mm0, packedbytes   ; <== error thrown here
    movq mm1, packedwords   ; <== here
    movq mm2, packeddwords  ; <== and here

    mov a0, 04d
    mov al, 0d  
    int 21h     
main ENDP
END main

I'm using masm on a 32 bit box.

1

There are 1 answers

1
Sebi On BEST ANSWER

I've figured it out. You can't use the registers directly; you can only place data via a pointer(at least with masm).

    mov edx, offset packedbytes
    movq mm0, [edx] 
    mov edx, offset packedwords
    movq mm1, [edx]
    mov edx, offset packeddwords   
    movq mm2, [edx] 

This should do the trick.