cmov


Moves data depending on the flag condition.

[Syntax]

-

cmov imm4, reg1, reg2, reg3

-

cmov imm4, imm, reg2, reg3

-

cmovcnd reg1, reg2, reg3

-

cmovcnd imm, reg2, reg3

 

The following can be specified for imm4:

-

Absolute expression having a value up to 4 bitsNote

Note

The cmov machine instruction takes an immediate value in the range of 0 to 15 (0x0 to 0xF) as the first operand.

 

The following can be specified for imm:

-

Absolute expression having a value of up to 32 bits

-

Relative expression

[Function]

-

Syntax "cmov imm4, reg1, reg2, reg3"

Compares the flag condition indicated by the value of the lower 4 bits of the value of the constant expression specified by the first operand with the current flag condition. If a match is found, the register value specified by the second operand is stored in the register specified by the fourth operand; otherwise, the register value specified by the third operand is stored in the register specified by the fourth operand.

-

Syntax "cmov imm4, imm, reg2, reg3"

Compares the flag condition indicated by the value of the lower 4 bits of the constant expression specified by the first operand with the current flag condition. If a match is found, the value of the absolute expression specified by the second operand is stored in the register specified by the fourth operand; otherwise, the register value specified by the third operand is stored in the register specified by the fourth operand.

-

Syntax "cmovcnd reg1, ret2, reg3"

Compares the flag condition indicated by string cnd with the current flag condition. If a match is found, the register value specified by the first operand is stored in the register specified by the third operand; otherwise, the register value specified by the second operand is stored in the register specified by the third operand.

-

Syntax "cmovcnd imm, reg2, reg3"

Compares the flag condition indicated by string cnd with the current flag condition. If a match is found, the value of the absolute expression specified by the first operand is stored in the register specified by the third operand; otherwise, the register value specified by the second operand is stored in the register specified by the third operand.

Table 5.30

cmovcnd Instruction List

Instruction

Flag Condition

Meaning of Flag Condition

Instruction Conversion

cmovgt

( (S xor OV) or Z) = 0

Greater than (signed)

cmov 0xF
cmovge

(S xor OV) = 0

Greater than or equal (signed)

cmov 0xE
cmovlt

(S xor OV) = 1

Less than (signed)

cmov 0x6
cmovle

( (S xor OV) or Z) = 1

Less than or equal (signed)

cmov 0x7
cmovh

(CY or Z) = 0

Higher (Greater than)

cmov 0xB
cmovnl

CY = 0

Not lower (Greater than or equal)

cmov 0x9
cmovl

CY = 1

Lower (Less than)

cmov 0x1
cmovnh

(CY or Z) = 1

Not higher (Less than or equal)

cmov 0x3
cmove

Z = 1

Equal

cmov 0x2
cmovne

Z = 0

Not equal

cmov 0xA
cmovv

OV = 1

Overflow

cmov 0x0
cmovnv

OV = 0

No overflow

cmov 0x8
cmovn

S = 1

Negative

cmov 0x4
cmovp

S = 0

Positive

cmov 0xC
cmovc

CY = 1

Carry

cmov 0x1
cmovnc

CY = 0

No carry

cmov 0x9
cmovz

Z = 1

Zero

cmov 0x2
cmovnz

Z = 0

Not zero

cmov 0xA
cmovt

always 1

Always 1

cmov 0x5
cmovsa

SAT = 1

Saturated

cmov 0xD

[Description]

-

If the instruction is executed in syntax "cmov imm4, reg1, reg2, reg3", the assembler generates one cmov machine instructionNote.

Note

The cmov machine instruction takes a register or immediate value in the range of -16 to +15 (0xFFFFFFF0 to 0xF) as the second operand.

 

-

If the following is specified as imm in syntax "cmov imm4, imm, reg2, reg3", the assembler generates one cmov machine instruction.

(a)

Absolute expression having a value in the range of -16 to +15

cmov    imm4, imm5, reg2, reg3
cmov    imm4, imm5, reg2, reg3

-

If the following is specified as imm in syntax "cmov imm4, imm, reg2, reg3", the assembler executes instruction expansion to generate multiple machine instructions.

(a)

Absolute expression exceeding the range of -16 to +15, but within the range of -32,768 to +32,767

cmov    imm4, imm16, reg2, reg3
movea   imm16, r0, r1
cmov    imm4, r1, reg2, reg3

(b)

Absolute expression having a value exceeding the range of -32,768 to +32,767

If all the lower 16 bits of the value of imm are 0

cmov    imm4, imm, reg2, reg3
movhi   HIGHW(imm), r0, r1
cmov    imm4, r1, reg2, reg3

Else

cmov    imm4, imm, reg2, reg3
mov     imm, r1
cmov    imm4, r1, reg2, reg3

(c)

Relative expression having #label or label, or that having $label for a label having no definition in the sdata/sbss-attribute section

cmov    imm4, #label, reg2, reg3
mov     #label, r1
cmov    imm4, r1, reg2, reg3
cmov    imm4, label, reg2, reg3
mov     label, r1
cmov    imm4, r1, reg2, reg3
cmov    imm4, $label, reg2, reg3
mov     $label, r1
cmov    imm4, r1, reg2, reg3

(d)

Relative expression having !label or %label, or that having $label for a label with a definition in the sdata/sbss-attribute section

cmov    imm4, !label, reg2, reg3
movea   !label, r0, r1
cmov    imm4, r1, reg2, reg3
cmov    imm4, %label, reg2, reg3
movea   %label, r0, r1
cmov    imm4, r1, reg2, reg3
cmov    imm4, $label, reg2, reg3
movea   $label, r0, r1
cmov    imm4, r1, reg2, reg3

-

If the instruction is executed in syntax "cmovcnd reg1, ret2, reg3", the assembler generates the corresponding cmov instruction (see "Table 5.30 cmovcnd Instruction List") and converts it to syntax "cmov imm4, reg1, reg2, reg3".

-

If the following is specified as imm in syntax "cmovcnd imm, reg2, reg3", the assembler generates the corresponding cmov instruction (see "Table 5.30 cmovcnd Instruction List") and converts it to syntax "cmov imm4, imm, reg2, reg3".

(a)

Absolute expression having a value in the range of -16 to +15

cmovcnd imm5, reg2, reg3
cmov imm4, imm5, reg2, reg3

-

If the following is specified as imm in syntax "cmovcnd imm, reg2, reg3", the assembler converts it to syntax "cmov imm4, imm, reg2, reg3", and executes instruction expansion to generate multiple machine instructions.

(a)

Absolute expression exceeding the range of -16 to +15, but within the range of -32,768 to +32,767

cmovcnd imm16, reg2, reg3
movea   imm16, r0, r1
cmov    imm4, r1, reg2, reg3

(b)

Absolute expression having a value exceeding the range of -32,768 to +32,767

If all the lower 16 bits of the value of imm are 0

cmovcnd imm, reg2, reg3
movhi   HIGHW(imm), r0, r1
cmov    imm4, r1, reg2, reg3

Else

cmovcnd imm, reg2, reg3
mov     imm, r1
cmov    imm4, r1, reg2, reg3

(c)

Relative expression having #label or label, or that having $label for a label having no definition in the sdata/sbss-attribute section

cmovcnd #label, reg2, reg3
mov     #label, r1
cmov    imm4, r1, reg2, reg3
cmovcnd label, reg2, reg3
mov     label, r1
cmov    imm4, r1, reg2, reg3
cmovcnd $label, reg2, reg3
mov     $label, r1
cmov    imm4, r1, reg2, reg3

(d)

Relative expression having !label or %label, or that having $label for a label with a definition in the sdata/sbss-attribute section

cmovcnd !label, reg2, reg3
movea   !label, r0, r1
cmov    imm4, r1, reg2, reg3
cmovcnd %label, reg2, reg3
movea   %label, r0, r1
cmov    imm4, r1, reg2, reg3
cmovcnd $label, reg2, reg3
movea   $label, r0, r1
cmov    imm4, r1, reg2, reg3

[Flag]

CY

---

OV

---

S

---

Z

---

SAT

---

[Caution]

-

If a constant expression having a value exceeding 4 bits is specified as imm4 of the cmov instruction, the assembler outputs the following message.
If the value exceeds 4 bits, the assembler masks the value with 0xF and continues assembling.

W0550011 : illegal operand (range error in immediate)