CZERO.NEZ

Conditional Zero Not Equal to Zero

CZERO.NEZ rd, rs1, rs2

Moves rs1 to rd if rs2 is zero, otherwise sets rd to zero.

Details

CZERO.NEZ conditionally zeroes rd: it writes zero to rd if rs2 is non-zero, otherwise writes rs1 to rd. Useful for branch-free conditional selection.

Pseudocode Operation

if (R[rs2] != 0) R[rd] = 0; else R[rd] = R[rs1];

Example

CZERO.NEZ x10, x11, x12

Encoding

Binary Layout
0000111
31:25
rs2
24:20
rs1
19:15
111
14:12
rd
11:7
0110011
6:0
 
Format R-Type
Opcode 0x33
Extension Zicond

Operands

  • rd
    Destination register (integer)
  • rs1
    Source
  • rs2
    Condition