GAS operand type mismatch for `cmovz '

I am trying to write a simple build program. For some reason, conditional moves seem to give me this error. If I replace them with the normal mov command it works. What's wrong with the following code?

    .section .data

supported:
    .asciz "AVX is supported"
notsupported:
    .asciz "AVX is not supported"


    .section .text
    .global main
main:
    movq $1, %rax
    cpuid
    andq $0x10000000, %rcx
    cmovnz $supported, %rdi
    cmovz $notsupported, %rdi
    callq puts

    movq $0, %rax
    ret
cpuid.S:15: Error: operand type mismatch for `cmovnz'
cpuid.S:16: Error: operand type mismatch for `cmovz'

      

+3


source to share


1 answer


If you look at the description CMOVcc

in the Intel manual, you can see that the original operand must be r/m64

(i.e. a 64-bit register or memory location). $supported

and $notsupported

are immediate and therefore do not qualify as r/m64

.

You can do something like this:



movabs $notsupported,%rdi
movabs $supported,%rbx
testq $0x10000000, %rcx   # checks the desired bit without clobbering %rcx
cmovnz %rbx,%rdi

      

+6


source







All Articles