Missing operator in expression AND command exited with code 1

I have the following code with a simple assembly procedure

.686p
.model flat, stdcall 
.mmx
.xmm


.code 
DataString DB 'AGIJKSZ', 0FFH ;

MyProc1 proc 

    vpbroadcastd ymm0, [4 bytes of JJJJ]
    vpcmpeqb ymm0, ymm0, [DataString] 
    vpmovmskb eax, ymm0 
    tzcnt eax, eax       
    ret        
MyProc1 endp 

end

However, when I try to compile it, I get Missing operator in expression on vpbroadcastd and

Error MSB3721 The command "ml.exe /c /nologo /Zi /Fo"Debug\JAAsm.obj" /W3 /errorReport:prompt /TaJAAsm.asm" exited with code 1.'

Is it becouse I chose wrong CPU or didn't include the instruction set, or there is something in my VS2015 project setup? Or maybe there is something missing in the code?

1 answer

  • answered 2018-03-13 22:05 Michael Petch

    [4 bytes of JJJJ] is not valid syntax, it appears someone was suggesting that you want to create a memory operand that points to 4 bytes each containing the letter J. I think the intention was to suggest doing something like:

    .686p
    .model flat, stdcall 
    .mmx
    .xmm
    
    .data
    DataString DB 'AGIJKSZ', 0FFH
    JMask DB 'JJJJ'
    
    .code 
    MyProc1 proc
        vpbroadcastd ymm0, dword ptr [JMask]
        vpcmpeqb ymm0, ymm0, [DataString] 
        vpmovmskb eax, ymm0 
        tzcnt eax, eax       
        ret        
    MyProc1 endp 
    
    end
    

    I created a 4 byte string called JMask and then use that as a memory operand for the vpbroadcastd instruction. Alternatively you could use this equivalent code:

    .686p
    .model flat, stdcall 
    .mmx
    .xmm
    
    .data
    DataString DB 'AGIJKSZ', 0FFH
    JMask DD 'JJJJ'
    
    .code 
    MyProc1 proc
        vpbroadcastd ymm0, [JMask]
        vpcmpeqb ymm0, ymm0, [DataString] 
        vpmovmskb eax, ymm0 
        tzcnt eax, eax       
        ret        
    MyProc1 endp 
    
    end
    

    This version creates Jmask as a DWORD that contains the 4 bytes JJJJ. The advantage to this is that it is unnecessary to override the memory operand with dword ptr like the first version of the program. The generated instructions for both versions will be identical.