cmovns
Move if not sign (SF == 0)
Copies the source into the destination when the sign flag is clear (SF is 0).
Pentium Pro and later
- Changes no flag
- Reads SF
Forms
Operands
reg- A general-purpose register matching the operation’s size, for example
al,ax,eaxorrax. The byte registersah,bh,chanddhcannot be used with a REX prefix, which is required byspl,bpl,sil,dilandr8–r15. r/m- A general-purpose register or memory location matching the operation’s size, for example
raxorqword [rbp-8]. The byte registersah,bh,chanddhcannot be used with a REX prefix, including when the memory address usesr8–r15.
The condition reads the current flags, as the conditional jumps do; the condition-code table lists the tests and the other spellings of each.
The source is read whether or not the condition holds, so a memory source must be readable even when nothing moves. With 32-bit operands the destination is written either way: when the condition fails it keeps its low 32 bits, but the upper half of its 64-bit register is still cleared. The 16- and 64-bit forms leave a destination they do not move into untouched. There is no immediate source and no memory destination.
Every x86-64 processor has these instructions; some older 32-bit processors do not.
global _start
section .text
_start:
mov rax, 12
mov rbx, 99
cmp rax, 12
cmovns rax, rbx ; copies rbx into rax only when the condition holds
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall