cmovbe

Move if below or equal (CF == 1 or ZF == 1)

Copies the source into the destination when the last comparison found below or equal (CF is 1 or ZF is 1).

Pentium Pro and later

Also written as: cmovna

Intel's reference: CMOVcc

CFPFAFZFSFDFOF –––––––
  • Changes no flag
  • Reads CF ZF

Forms

Operands

reg
A general-purpose register matching the operation’s size, for example al, ax, eax or rax. The byte registers ah, bh, ch and dh cannot be used with a REX prefix, which is required by spl, bpl, sil, dil and r8–r15.
r/m
A general-purpose register or memory location matching the operation’s size, for example rax or qword [rbp-8]. The byte registers ah, bh, ch and dh cannot be used with a REX prefix, including when the memory address uses r8–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
        cmovbe rax, rbx      ; copies rbx into rax only when the condition holds

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall