Search code examples
windowsassemblyx86masmmmx

I can't assemble movd (MMX) instruction in my visual c express ediion 2008


when I try to compile movd instruction it is showing error as

error A2085:instruction or register not accepted in current CPU mode

My code is as follows:

.386                
.model flat, c                                           
.code

add_func_asm PROC                                                 
movd     eax, ebx
ret    
add_func_asm endp

END

this is .asm file and I called this function from a C file

I fixed it by using below code

.586    
.mmx            
.model flat, c                                           
.code                          
add_func_asm PROC                                                 
movd     mm1, ebx
ret    
add_func_asm endp

END

Solution

  • .386
    

    That cannot work, the 386 processor didn't have this instruction. You have to target .586 (Pentium and up) and explicitly state that you want to use the MMX instruction set. Fix:

    .586
    .mmx
    

    That will get the assembler to accept the MOVD instruction. Next thing you'll have to do is fix the operands. Moving from ebx to eax is not valid, and pointless, you'll have to specify an MMx register.